09. Lab - EC2 Auto Scaling
# EC2 Auto Scaling
In this hands-on exercise, you will use Auto Scaling to automatically launch Amazon EC2 instances in response to conditions you specify. You will also see auto scaling in action as it automatically provisions a replacement instance.
Prerequisites:
- AWS Account
Topics Covered:
By the end of this lab, you will be able to:
- Use auto scaling to launch EC2 instances
- Create an auto scaling group
- Test auto scaling
Steps:
Create a Launch Configuration
- On the AWS Management Console page, type
EC2in theFind Servicesbox and then selectEC2. - Scroll down to the
Auto Scalingsection on the left-hand menu and clickAuto Scaling Groups. - Click the
Create Auto Scaling groupbutton. - Review the steps and click on
Get started. - Create a launch configuration by first selecting an Amazon Machine Image (AMI). In the row for
Amazon Linux 2 AMI (HVM), SSD Volume Type, click theSelectbutton.
Note: An AMI is a template for an instance that indicates the operating system, an application server, and applications.
- Confirm that
t2.microis selected. - Click
Next: Configure details. - Enter a name of your choosing in the
Namefield. - Expand the
Advanced Detailssection. - Next to
IP Address Type, click onAssign a public IP address to every instance. - Click
Next: Add Storage. Review the screen. - Click
Next: Configure Security Group. - Ensure
Create a new security groupis selected. - Click
Review. - Click on
Create launch configuration. - On the
Select an existing key pair or create a new key pair, selectCreate a new key pair, enter a key pair name in theKey pair namefield, and clickDownload Key Pair. - Click on
Create launch configuration.
- On the AWS Management Console page, type
Create an Auto Scaling Group
- On the
Create Auto Scaling Grouppage, enter a group name of your choosing in theGroup namefield, ensure theGroup sizeis set to1, forNetworkleave the default value. If no default value is shown, click onCreate new VPC, and select the firstSubnetby clicking in theSubnetfield. - Click
Next: Configure scaling policies. - Ensure that
Keep this group at its initial sizeis selected. - Click
Review. - Review the selected options and click
Create Auto Scaling group. - Click
Close.
- On the
Verify your Auto Scaling Group
- Verify that the group has launched your EC2 instance by first ensuring the auto scaling group you just created is selected and examining the
Detailstab shown on the bottom of the screen. - Click the
Activity Historytab. The status of your instance should beSuccessful, which means the instance is launched. - Click on the
Instancestab. Notice theLifecyclecolumn statesInService.
- Verify that the group has launched your EC2 instance by first ensuring the auto scaling group you just created is selected and examining the
Test Auto Scaling
- Click on the
Instancestab. - Under the
Instance IDcolumn, click on the blue Instance ID link. - You will be taken to the Amazon EC2 console Instances page.
- Your instance should be selected.
- Click the
Actionsbutton, scroll down toInstance State, and selectTerminate. Then selectYes, Terminate. - In the left-hand navigation pane, click
Auto Scaling Groups. - Click the
Instancestab. You will eventually see a new instance appear. If the new instance doesn’t appear, click refresh occasionally to update the list. - Click on the
Activity Historytab to review the history for the Instance.
- Click on the
Delete Auto Scaling Resources
- At the top of the screen, click the
Actionsbutton next to theCreate Auto Scaling group. - Click the
Deleteoption.
- At the top of the screen, click the
Use Auto Scaling to Automatically Launch Amazon EC2 instance
Task Feedback:
Well Done!