Morgan Clark
6 min readApr 13, 2022

How to utilize an Amazon Auto Scaling group to launch multiple EC2 instances due to a CPU’s utilization capacity.

Good afternoon, everyone!!! I present to you my latest project, as a guest in Cohort Blue of (Level Up In Tech) we were challenged with this task. It was not specified which method to utilize either the AWS CLI or the AWS Management Console, I opted for the AWS Management console instead.

Project task:
Create a VPC with CIDR 10.10.0.0/16 with an Auto Scaling group using t2.micro instances. All instances should have Apache installed on each instance with the ability to check any random IP address and be able to produce a test page.

The instance min and max should be 2 and 5 and should have a scaling policy with CloudWatch to scale after CPU utilization is above 80%

Extra Credit: Do all this using CloudFormation.

After the Auto Scaling group has been created, find a stress tool to be able to stress an instance above 80% to see if your scaling policy works!

  1. Create a custom VPC with a CIDR 10.10.0.0/16, select the VPC, subnets, etc. options, by doing these other requirements will also be created and “associated” with the new VPC created below.

2. The Create VPC workflow contains the numerous parts that were created when selecting VPC, subnets, etc. and did not any require manual creation. Several of the entries contain a link to another item and can be reached by clicking that link. Notice that the fourth subnet contains a link and a red arrow. Below you will see the details for that subnet.

2. Enter a name and a version description for the template.
3. Also select the option to receive guidance on setting up a template that can be used with EC2 Auto Scaling.
4. Select an Amazon Machine Image (AMI) type, I selected the Free tier eligible option as shown below.

5. Select an instance type, based on our task, I selected the t2.micro type.

6. I also generated a new Key-Pair to be utilized with the instance. {See above
7. For the network settings, I selected Create security group, which provided additional options and selections or parameters. I entered a security group name, a brief description, located and selected the VPC that was created in step 1. Then to provide both SSH (port 22) and HTTP (port 80) access, I created security group rules.

  • note: Whenever configuring a security group rule, it is highly recommended to not use 0.0.0.0/0 for your CIPR, because it allows full access and can be a security issue.

8. In the Network interface configuration section, for the Auto-assign public IP address field, click the drop-down and select Enable to allow the network interface to automatically assign public IP address.

9. Another item that was listed in the steps for this project was to utilize a scaling policy with CloudWatch to scale after CPU utilization is above 80%. What is CloudWatch, you might ask? Amazon CloudWatch is a monitoring and observability service built for DevOps engineers, developers, site reliability engineers (SREs), IT managers, and product owners. CloudWatch provides you with data and actionable insights to monitor your applications, respond to system-wide performance changes, and optimize resource utilization. (Reference: What is Amazon CloudWatch?)

9. We also were required to include an Apache webserver that would launch with each instance. That was accomplished by way of the User data info shown below. This is referred to as a bootstrap, which are used to complete certain steps or tasks prior to the server being made available to users. For example, in the bootstrap below we ran software updates, install a service, and run other commands.

10. Review the settings and then click the Create launch template button.
11. The template was successfully created.

12. Create the Auto Scaling group for this project.

13. Select the launch template and then click the Next button.

14. Select the VPC and two public AZ and subnets, I selected the US-East-1 AZs.

15. Enter the desired values for Desired, minimum, and maximum capacity options.

16. For scaling policies, though optional, select Target tracking scaling policy and enter the desired Target value and number of seconds that an instance will need to warm up before including in metric.

17. Though not an item on our project task, I created a subscription for AWS SNS (SNS=Simple notification service) and selected email.

18. A sample of the email that was sent to me for confirmation of my email address to receive the notification emails.

19. Creating a SNS topic to be used to send out the notifications.

20. After the instances were launched, I received the above email with info regarding the launch.

21. Upon locating the public IPv4 address that was assigned to my instance, I entered it into a browser and the page below was the result. It displayed the test page for the Apache Http server that was setup by using the data from the bootstrap step 9.

22. CloudWatch alarm states were clear without issue.

Morgan Clark
Morgan Clark

Written by Morgan Clark

Sr. Telecom Engineer, pursuing new skills and career opportunities in DevOps.

No responses yet