Skip to main content

Setting Up an Application Load Balancer with an Auto Scaling Group and Route 53 in AWS

Hands-On Lab

 

Photo of Julie  Elkins

Julie Elkins

AWS Training Architect I in Content

Length

01:00:00

Difficulty

Beginner

In this hands-on lab, we will set up an Application Load Balancer with an Auto Scaling group and Route 53 to make our website highly available to all of our users. First, we will create and configure an Application Load Balancer. Then, we'll create and configure Auto Scaling and review how it works in different scenarios. Finally, we will configure a Route 53 CNAME alias record that will be an alias for our Application Load Balancer to serve our website to all users.

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.

Setting Up an Application Load Balancer with an Auto Scaling Group and Route 53 in AWS

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. Finally, 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.

Create and Configure an 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: ALB
    • 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. Select both Availability Zones.
  9. In the Tags section, add a tag of:
    • Key: Name
    • Value: LAALB
  10. Click Next: Configure Security Settings.
  11. Click Next: Configure Security Groups.
  12. Uncheck the default security group selection.
  13. Select the security group whose name starts with cfst-.
  14. Click Next: Configure Routing.
  15. In the Target group section, set the following values:
    • Target group: New target group
    • Name: ALBTG
    • Target type: Instance
    • Protocol: HTTP
    • Port: 80
  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.

Create and Configure an Auto Scaling Group

Create Launch Configuration

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

  2. Click Create launch configuration.

  3. Select the Amazon Linux 2 AMI.

  4. Select the t2.micro.

  5. Click Next: Configure details.

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

    • Name: LAASG
    • 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 Next: Add Storage.

  11. Leave the defaults, and click Next: Add Configure Security Group

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

  13. Select the security group whose name starts with cfst-.

  14. Click Review.

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

  16. In the key pair dialog, select Create a new key pair.

  17. Give it a name of "ASGKeyPair".

  18. Click Download Key Pair.

  19. 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: ASGTargetGroup
    • 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
    • Metric type: Average CPU Utilization
    • Target value: 80
    • Instances need: 180
  9. Click Next: Configure Notifications.
  10. Click Next: Configure Tags.
  11. Give it a Key of "NAME" and a Value of "ASG".
  12. Click Review.
  13. Click Create Auto Scaling group.
  14. Once it's successfully created, click Close.
  15. With the Auto Scaling group selected, click Actions > Edit.
  16. In the Edit details dialog, make the following changes:
    • Desired Capacity: 2
    • Min: 2
    • Target Groups: ALBTG
  17. Click Save.
  18. Right-click Instances in the left-hand menu to open it in a new browser tab. We should see a new instance is being provisioned.

Test Auto Scaling Group

  1. On the instances page, select the new instance.
  2. Click the Actions dropdown and select Instance State > Stop.
  3. In the confirmation dialog, click Yes, Stop.
  4. Once it's stopped, we should see a new instance being created.

Create and Configure a CNAME Alias in Route 53

Test the DNS Name

  1. Select one of the instances.
  2. In the Description section, 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, copy its DNS name.
  7. Paste it into a new 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 Go to Record Sets.
  5. Click Create Record Set.
  6. Set the following values:
    • Name: www
    • Type: A — IPv4 address
    • Alias: Yes
    • Alias Target: Select the ALB listed under ELB Application load balancers
    • Routing Policy: Simple
    • Evaluate Target Health: No
  7. Click Create.
  8. Once it's created, copy the alias record (in the Name column).
  9. Paste it into a new browser tab — it should result in the Linux Apache test page.

Conclusion

Congratulations on completing this hands-on lab!