‫So let's go ahead
‫and practice with network load balancers.
‫So to do so,
‫I'm going to create a load balancer
‫and I will choose a network load balancer.
‫Then I will call this one DemoNLB.
‫It's going to be internet-facing of IPv4.
‫And then for network mappings,
‫I will deploy it in three different availability zones,
‫but as you can see here, there is an IPv4 setting.
‫This is because the NLB has a one-fixed IP address
‫per AZ that you're deploying to.
‫And you can either choose a IP address assigned by AWS.
‫It's going to be public because I chose a IP,
‫an internet-facing type of network load balancer.
‫But if you had an Elastic IP,
‫you could use that Elastic IP instead
‫on your network load balancer.
‫So we're good.
‫We have three AZs
‫and we'll have three fixed IPs at the end of it.
‫And right now,
‫I need to create a specific target group for our NLB.
‫So it's going to be based on instances.
‫And I'll call this one demo-tg-nlb.
‫And the protocol is TCP on port 80.
‫I have to choose TCP for my network load balancer.
‫And then the health check protocol
‫can be TCP, HTTP, or HTTPS.
‫So we choose whatever we want.
‫If we know we have an HTTP application,
‫it's not a bad idea to use
‫an HTTP type of protocol for the health check.
‫So I use slash as my health check path.
‫And then the health threshold is going to be two,
‫the timeout is going to be two seconds,
‫and the interval is going to be five.
‫Let's click on Next.
‫We have two available instances.
‫So let's include them as pending below
‫and create our target group.
‫So now, our target group is created.
‫I'm going to refresh this page.
‫And as you can see,
‫now my demo target group NLB is appearing.
‫So we're good to go.
‫We have defined our NLB.
‫Now, let's create our load balancer.
‫And it's going to take a few minutes
‫for it to become active.
‫So our network load balancer is now created.
‫And if I click on it, and open the DNS name,
‫and open a new tab, as you can see, it does not work.
‫So let's investigate.
‫We're going to go into the target group
‫of our network load balancer,
‫and we're going to look at the targets,
‫and while two of them are unhealthy.
‫This is zero because we know that the instances
‫are healthy on my other load balancer.
‫So what's happening?
‫Well, it turns out that when you use
‫a network load balancer,
‫you don't define a security group for it.
‫That means that all the traffic
‫goes through the network load balancer
‫and goes straight into the EC2 instances.
‫And this is the security group of the EC2 instances
‫that is going to decide whether or not
‫the traffic is allowed.
‫But if we go back to our EC2 instances
‫and look at the security group we had defined from before,
‫the launch-wizard-1,
‫and look at the inbound rules, and edit them,
‫well, it turns out that we only allowed port 80
‫coming from the application load balancer.
‫And so therefore,
‫the traffic doesn't work for public traffic.
‫So let's add a rule instead to fix this temporarily
‫while we still have a network load balancer
‫to allow HTTP on port 80 from anywhere.
‫Let's save this rule.
‫And now it's saved.
‫So back into our target group now.
‫Let's refresh this page.
‫And we are doing health checks every five seconds.
‫And hopefully very soon it's going to start to show healthy.
‫And as you can see now, yes, my two instances are healthy
‫because we made changes to the security group.
‫If I go into my load balancer and refresh, yes,
‫as we can see I see my Hello World.
‫And if I refresh the page more and more,
‫it's going to switch between different EC2 instances.
‫So that's really good.
‫We have exactly the behavior we want.
‫And we have our network load balancer nicely working.
‫So to finish this hands-on,
‫you need to just clean up after yourself.
‫So to do so, first, delete the network load balancer.
‫So let's delete it.
‫And yes, I confirm.
‫Number two, we can delete the target group itself.
‫So yes, we delete it.
‫And finally, into our inbound rules of our security group,
‫we can go ahead
‫and actually delete the rule
‫that allowed HTTP from anywhere.
‫So this is this first one for me and save the rules.
‫And that's it.
‫So we've seen network load balancers.
‫I hope you liked it.
‫And I will see you in the next lecture.