Start course

Compute Fundamentals for AWS offers you an updated introduction to AWS's cornerstone compute services, and provides a foundation as you build your compute skills for AWS. It includes coverage of:

- Amazon Elastic Compute Cloud (EC2)
- Elastic Load Balancers (ELBs)
- Auto Scaling
- Amazon EC2 Container Registry and Services (ECR and ECS)
- AWS Elastic Beanstalk
- AWS Lambda

Do you have questions on this course? Contact our cloud experts in our community forum.


EC2 is one of the most used features of AWS. The attraction of EC2 is enhanced by services like auto-scaling groups. With auto-scaling groups, you can scale your instances based on specific conditions such as load, time of day, or on a regular schedule. Let's take a look at this invaluable feature. There are two things that you need to take advantage of auto-scaling, which are a launch configuration and an auto-scaling group. The launch configuration specifies EC2 instance details such as the Amazon Machine Image to use, the instance type, storage and more. To create a launch configuration, from the EC2 dashboard select launch configurations from the auto-scaling menu and click create auto-scaling group. And you will see the create auto-scaling group page that provides an overview of the process. Click the create launch configuration to commence the wizard. On the choose AMI page, you need to select an AMI which will serve as a template for all your instances that will be launched as part of this configuration. For the purpose of this demonstration select the 64-bit Amazon Linux AMI and on the instance type page we will select T2 Micro and click next configure details. In the main field, you need to enter a name for the launch configuration and we shall enter, demo-LC. If you expand the advanced details section here you could pass user data that when you launch the instance to perform automatic configuration task and run scripts after the instance starts. At this point we will click skip to review and on the review page we will click create launch configuration. Please note that in the real world scenario we would configure the security groups to restrict access but for the purpose of an introduction, we are skipping over this step. When prompted to select an existing key pair and acknowledge that you have the corresponding key, click create launch configuration to create your launch configuration. Once the launch configuration has been created it cannot be modified. Changes require a new launch configuration to be created. This is necessary to ensure the consistency of running instances launched by the auto-scaling group. The next step is to configure and auto-scaling group which defines the conditions for scaling using the launch configuration we just created. To create an auto-scaling group on the configuration page we will enter a group name, demo-ASG. And for the group size, we will leave it at the default of one. This way determines the minimum number of instances that should be running. Also called the desired capacity. Next, we will select the VPC and relevant subnets. And then click on advanced details and you will notice that you have the option to associate a load balancer with the auto-scaling group. Click next configure scaling policies. In the configure scaling policies page, you can specify to keep the group at the initial size with which we set or you can use a policy to scale dynamically using cloud watch alarms. You can trigger a scale up or scale down event either by a specific number of instances or by a percentage of the group. To prevent scaling too fast you add a wait period before the group responds to other triggers. Auto-scaling groups can also be scheduled instead of triggered by alarms. For the purpose of this demo, we will leave it set to the initial size and click review and then click create auto-scaling group. And from the status page click close. This has now launched an instance and you can see this from reviewing the activity history. Right now we have configured a single instance with a desired number of one and a minimum and a maximum of one instance. So what would happen if we went to the console and selected the instance and then clicked terminate? In this scenario, as we have a policy with a minimum of one, it will have to replace this instance. As we have a cool down period of 300 seconds, 5 minutes, we won't see any activity until then, at which point we will see an entry for the termination that we initiated and then a launch for the new instance. A good practice is to create an auto-scaling group with the min/max and desired set to one. And that way, if your EC2 instance goes down, a new instance will be brought up automatically. A very useful tip that is easy to set up. There is no additional cost for using auto-scaling as you only pay for the EC2 instances and other resources whilst they are running. Auto-scaling is a core service for efficiently managing system capacity and serves as an important foundation for building highly scalable environments.

About the Author
Learning Paths

David's acknowledged hands on experience in the IT industry has seen him speak at international conferences, operate in presales environments and conduct actual design and delivery services.

David also has extensive experience in delivery operations. David has worked in the financial, mining, state government, federal government and public sectors across Asia Pacific and the US