Skip to main content

Set Up an Elastic Load Balancer, Auto Scaling, and Route 53 in an AWS Environment

Hands-On Lab

 

Photo of Tia  Williams

Tia Williams

AWS Training Architect II in Content

Length

01:00:00

Difficulty

Beginner

In this hands-on lab, we will create an Application Load Balancer. Then, we'll configure Auto Scaling and review how it works in different scenarios. Afterward, we will configure a Route 53 CNAME alias record that will be an alias for our Application Load Balancer.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Set Up an Elastic Load Balancer, Auto Scaling, and Route 53 in an AWS Environment

Introduction

In this hands-on lab, we will create an Application Load Balancer. Then, we'll configure Auto Scaling and review how it works in different scenarios. Afterward, we will configure a Route 53 CNAME alias record that will be an alias for our Application Load Balancer.

Solution

Log in to the live AWS environment using the credentials provided. Make sure you're in the N. Virginia (us-east-1) region throughout the lab.

Here is the file containing the bash script for this lab.

Configure the Application Load Balancer

  1. Navigate to EC2.
  2. Select Load Balancers in the left-hand menu.
  3. Click Create Load Balancer.
  4. In the Application Load Balancer card, click Create.
  5. In the Basic Configuration section, set the following values:
    • Name: LALoadBalancer
    • Scheme: internet-facing
    • IP address type: ipv4
  6. Leave the settings in the Listeners section as-is.
  7. In the Availability Zones section, select the VPC that has two availability zones.
  8. Check both availability zones.
  9. Click Next: Configure Security Settings.
  10. Click Next: Configure Security Groups.
  11. Uncheck the default security group selection.
  12. Select the security group whose name starts with cfst.
  13. Click Next: Configure Routing.
  14. In the Target Group section, set the following values:
    • Target group: New target group
    • Name: LATargetGrp
    • Target type: Instance
    • Protocol: HTTP
    • Port: 80
  15. In the Health checks section, set the following values:
    • Protocol: HTTP
    • Path: /
  16. In the Advanced health check settings section, set the following values:
    • Port: traffic port
    • Healthy threshold: 3
    • Unhealthy threshold: 2
    • Timeout: 5
    • Interval: 10
    • Success codes: 200
  17. Click Next: Register Targets.
  18. Leave the settings as-is.
  19. Click Next: Review.
  20. Click Create.

Configure and Test Auto Scaling

Create Launch Configuration

  1. Select Launch Configurations from the left-hand menu.

  2. Click Create launch configuration.

  3. Select the Amazon Linux AMI (not Amazon Linux 2 AMI).

  4. Select the t2.micro.

  5. Click Next: Configure details.

  6. On the details page, set the following values:

    • Name: LALaunchConfig
    • Purchasing option: Uncheck
    • IAM role: Leave as-is
    • Monitoring: Uncheck
  7. Expand the Advanced Details section.

  8. In the User data box, enter the following bash script:

    #!/bin/bash
    yum update -y
    yum install httpd -y
    service httpd start
    chkconfig httpd on
  9. For IP Address Type, select Assign a public IP address to every instance.

  10. Click Skip Storage.

  11. On the security group page, choose Select an existing security group.

  12. Select the security group whose name starts with cfst.

  13. Click Review.

  14. On the review page, click Create launch configuration.

  15. In the key pair pop-up, select Create a new key pair.

  16. Give it a name of "elbautoscale".

  17. Click Download Key Pair.

  18. Once it's downloaded, click Create Launch configuration.

Create Auto Scaling Group

  1. Click Create an Auto Scaling group using this launch configuration.
  2. Set the following values:
    • Group name: LAAutoscale
    • Group size: 1
    • Network: Select the VPC from earlier that has two subnets in it
    • Subnet: Select both subnets (us-east-1a and us-east-1b)
  3. Expand the Advanced details section.
  4. Set the Health Check Grace Period to 180.
  5. Click Next: Configure scaling policies.
  6. Select Use scaling policies to adjust the capacity of this group.
  7. Change it to scale between 1 and 3 instances.
  8. In the Scale Group Size section, set the following values:
    • Name: LAScalingGrp
    • Target value: 80
    • Instances need: 180
  9. Click Review.
  10. Click Create Auto Scaling group.
  11. Once it's successfully created, click View your Auto Scaling groups.
  12. Right-click Instances in the left-hand menu to open it in a new browser tab.
  13. On the Auto Scaling groups dashboard, click the Actions dropdown and select Edit.
  14. In the Details tab below, set the following values:
    • Desired Capacity: 2
    • Min: 2
    • Target Groups: Select the one listed that we created earlier
  15. Click Save.
  16. Back in the instances browser tab, refresh the table — you should see a new instance being provisioned.

Test Auto Scaling Group

  1. On the instances page, select one of the instances in us-east-1a.
  2. Click the Actions dropdown and select Instance State > Stop.
  3. In the confirmation pop-up, click Yes, Stop.
  4. Right-click Auto Scaling Groups in the left-hand menu to open it in a new browser tab.
  5. On the Auto Scaling groups page, in the Instances tab below, refresh the table to see one instance's health status has changed to Unhealthy.
  6. Back in the instances browser tab, observe the instance has now stopped.
  7. On the Auto Scaling page, refresh the instances table and observe it's terminated the instance and is launching a new one.
  8. Back again to the instances browser tab, refresh the table and observe it's started provisioning a new instance.

Create an Alias Record with Route 53 for the Application Load Balancer

Test the DNS Name

  1. Select one of the instances.
  2. In the Description section below, copy its public DNS name.
  3. Paste the DNS name into a new browser tab, which should result in the Linux Apache test page.
  4. Back in the AWS console, right-click Load Balancers in the left-hand menu to open it in a new browser tab.
  5. Select the load balancer listed.
  6. In the Description section below, copy its DNS name.
  7. Paste it into a browser tab — it should also result in the Linux Apache test page.

Create Alias Record

  1. Navigate to Route 53 in the AWS console.
  2. Click Hosted zones.
  3. Select the listed zone.
  4. Click Create Record Set.
  5. Set the following values:
    • Name: blog
    • Type: A — IPv4 address
    • Alias: Yes
    • Alias Target: LALoadBalancer
    • Routing Policy: Simple
    • Evaluate Target Health: No
  6. Click Create.
  7. Once it's created, copy the alias record (in the Name column).
  8. Paste it into a browser tab — it should result in the Linux Apache test page.

Conclusion

Congratulations on completing this hands-on lab!