- Lab
- A Cloud Guru
Creating a Custom AMI and Deploying an Auto Scaling Group behind an Application Load Balancer
During this hands-on lab you will undergo the process of standing up a working Web Server on Amazon EC2, creating a custom AMI using the instance, and then deploying an Auto Scaling Group using the newly created AMI.
Path Info
Table of Contents
-
Challenge
Create AMI of Amazon EC2 Instance
- Create a new AMI using the running Amazon EC2 instance and name it
WebServer
.
- Create a new AMI using the running Amazon EC2 instance and name it
-
Challenge
Create Launch Template
- Create a new Launch Template named
WebServerLT
using the recently createdWebServer
AMI. - For Firewall (security groups), select Create security group, name it
AllowVpcHTTP
, select (Your Custom VPC), and set up the Inbound Security Group Rules to allow HTTP from the VPC (Should have a CIDR of10.0.0.0/16
). - Under Advanced details, for the IAM instance profile menu, find and select
OurSystemsManagerEC2Profile
. - Find Detailed CloudWatch monitoring Info and select
Enable
from the dropdown. - Finally, paste the User Data code from the GitHub repo into the
User data
field and create the launch template.
- Create a new Launch Template named
-
Challenge
Create Auto Scaling Group and Scaling Policy
Create Auto Scaling Group
- After you've confirmed your new AMI is available, create a new Auto Scaling Group called
WebServer-asg
using the recently createdWebServerLT
Launch Template. - Set the Auto Scaling Group VPC to
Your Custom VPC
. - Deploy the group into the 3 private subnets.
- Attach the Auto Scaling Group to a new Internet-facing Application Load Balancer that lives within the 3 public subnets in
Your Custom VPC
. - Forward the HTTP traffic to a new Target Group containing the Auto Scaling Group.
- Set the Auto Scaling Group desired capacity to
1
. - Set the Auto Scaling Group minimum capacity to
1
. - Set the Auto Scaling Group maximum capacity to
3
. - Create a Target Tracking scaling policy for your Auto Scaling Group.
- For the scaling policy set the metric type to
Average CPU Utilization
- Set the target value to
50
.
Create New ALB Security Group
- Create a new VPC Security Group for the Application Load Balancer (ALB).
- Name it
OurALBSecurityGroup
. - Deploy it into
Your Custom VPC
. - Add an inbound rule that allows all HTTP traffic from all IPv4 addresses.
- Attach the security group to your new Application Load Balancer fronting your Auto Scaling Group.
If the settings are not discussed, leave as default.
- After you've confirmed your new AMI is available, create a new Auto Scaling Group called
-
Challenge
Test Scaling
- Connect to the Auto Scaling Group instance using Session Manager.
- Stress test the CPU using the installed
stress
application through the following command:
sudo stress --cpu 2
After a few minutes, this should trigger a scaling action for the Auto Scaling Group.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.