Amazon EC2 Auto Scaling

Ronnie Ford
5 min readSep 29, 2020

Purpose of this lab: walks you through the process for setting up a basic infrastructure for Amazon EC2 Auto Scaling. Before you create an Auto Scaling group for use with your application, review your application thoroughly as it runs in the AWS Cloud. Consider the following:

1. Decide what availability zones the Auto Scaling group will cover.

2. Can you use existing Amazon resources?

3. Are you wanting to scale to increase/decrease capacity or do you just want to make sure you have a set number of servers running? Amazon EC2 can do both at the same time.

Step 1: Create a launch template

For this step, you’ll create a launch template that specifies the type of EC2 instance that Amazon EC2 Auto Scaling creates for you.

  1. Go to EC2 in the navigation window select “launch templates”.

2. Select “create a new template”.

3. Enter the name and description of your template.

4. Enter the AMI ID (use a Linux 2 AMI), and choose your instance type (t2.micro).

5. Leave the network type as VPC

6. Select your security group that you plan to use (if you don’t select a security group the instance will automatically default to the security group of your VPC.)

7. Leave the network interface section empty.

8. Scroll down and choose create launch template.

9. On the confirmation page select “create auto scaling group”.

Step 2: Create an Auto Scaling group

An Auto Scaling group is lets you build scaling plans that automate how groups of different resources respond to changes in demand.

  1. Name your auto scaling group and choose your launch template.

2. Select next.

3. On the configure page select “adhere to launch template”, select your VPC (default), and the subnets (for high availability select subnets in multiple availability zones).

4. Keep everything else default, and “choose skip to review”.

5. On the review page check to make sure everything is correct, and select “create auto scaling group”.

Step 3: Verify your Auto Scaling group

Now that you have created an Auto Scaling group, you are ready to verify that the group has launched an EC2 instance.

  1. Click on the check box next to your auto scaling group, and select the details tab. The details tab shows information showing information about the Auto Scaling group.

2. Choose the second tab, Activity. Under Activity history, you can view the progress of activities that are associated with the Auto Scaling group. The Status column shows the current status of your instance. While your instance is launching, the status column shows PreInService. The status changes to Successful after the instance is launched. You can also use the refresh button to see the current status of your instance. (Old console: The Activity History tab is where you can view the status of the instance. While your instance is launching, the status column shows In progress.)

3. On the instance management tab you can see the status of the instance.

4. Verify that your instance launched successfully. It takes a few minutes for an instance to launch. The Lifecycle column shows the state of your instance. Initially, your instance is in the “Pending” state. After an instance is ready to receive traffic, its state will be “InService”.

Step 4: Terminate an instance in your Auto Scaling group

You can use these steps to learn more about how Amazon EC2 Auto Scaling works, specifically, how it launches new instances when necessary. The minimum size for the Auto Scaling group that you created in this tutorial is one instance. Therefore, if you terminate that running instance, Amazon EC2 Auto Scaling must launch a new instance to replace it.

  1. Click on “instance” in the navigation window.

2. Select the instance or instances that you want to terminate. Select actions -> instance state -> terminate. (I deleted all three of my instances).

3. Go back to your auto scaling group and look at the activity tab. You can see the instances were terminated and the new instance was created. The default cooldown for the Auto Scaling group is 300 seconds (5 minutes), so it takes about 5 minutes until you see the scaling activity. In the activity history, when the scaling activity starts, you see can see an entry for the termination of the first instance, and you can see an entry for the launch of a new instance.

4. Go back to your instances and you can see the new instances are being initiated/created.

Step 5: terminate your environment.

Feedback

Any constructive feedback is welcomed as I’m still learning, and want to to continue to develop my skills.

--

--