Configuring AWS Auto Scaling Rolling Updates

Hands-On Lab

 

Photo of Craig Arcuri

Craig Arcuri

AWS Training Architect II in Content

Length

00:30:00

Difficulty

Intermediate

Welcome to this hands-on AWS Learning Activity in which you will learn to perform Auto Scaling Rolling Updates. A common scenario is the need to perform updates on the instances in an Auto Scaling Group. It is not possible to update Launch Configurations directly which complicates updating Auto Scaling Groups without incurring downtime. Using Auto Scaling Rolling updates is the answer. Rolling updates allow you to update instances (the instances are actually replaced), while allowing you to specify that at least one instance is always active. In this way, downtime can be avoided while the update is taking place.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Configuring AWS Auto Scaling Rolling Updates

In this lab, we have an instance that is a t2.micro. Unfortunately, it is too small for what we need. We've been asked to upgrade the instance to a t2.medium, and to avoid any downtime. To do so, we will create a new launch configuration with the desired size, and then use auto-scaling rolling updates to replace the old configuration. This will keep us from having any downtime, but also allows us to update our autoscaling group.

Before we begin, we need the cloud formation templates, which are located in the Downloads section of the course. The templates are named Auto Scaling Rolling Updates 1 and Auto Scaling Rolling Updates 2. You only need to download Auto Scaling Rolling Updates 1 as it is.

With the templates at the ready, log in to the AWS environment using the cloud_user credentials provided. Once inside the AWS account, make sure us-east-1 (N. Virginia) is our selected region.

Create an Autoscaling Group

To begin, we need to create the original autoscaling group that we will later update. From the Services dropdown, select CloudFormation from under the Management & Governance section. In here, select Design Template. In the Template tab, at the bottom of the page, paste in the information from the Auto Scaling Rolling Updates 1. Once that's done, select the Validate Template button at the top of the screen, which looks like a checkmark in a box.

With our validated template, select the Create Stack button (which looks like a cloud with an arrow in it) at the top of the page. This one looks like a cloud with an arrow in it. On the Select Template page, select Next. On the Specify Details page, enter the name of our stack into the Stack name field. For this lab, we will name it OriginalASG. Select Next, and then select Next again on the Options page. On the Review page, select Create.

Refresh the Stacks page, and we'll see ours,OriginalASG, appear in the list. We can review the information for this stack by selecting it, and then watching the Resources tab in the lower part of the screen.

Once the stack reads CREATE_COMPLETE, we can continue with the lab.

Update the Autoscaling Group

Now that our stack is created, use the Services dropdown and select EC2 under the Compute section. Then select the Instances section. Verify that we have two running t2.micro instances.

With our instances running, use the Services dropdown and go back to CloudFormation under the Management & Governance section. Select our OriginialASG stack, then select Actions and choose Update Stack.

On the Select Template page, select View/Edit template in Designer. On the Template tab, delete all of the information present. In our blank template area, paste in the information from the Auto Scaling Rolling Updates 2 template. We can see at the bottom of this template, on the line InstanceType, our instance type is now a t2.medium:

            ],
            "InstanceType": "t2.medium"
        }

Also note that we have new information under the WebServerGroup section:

    "WebServerGroup": {
        "Type": "AWS::AutoScaling::AutoScalingGroup",
        "UpdatePolicy": {
            "AutoScalingRollingUpdate": {
                "MaxBatchSize": "4",
                "MinInstancesInService": "1"

The information under the UpdatePolicy tells us that we must always have one instance in service at all times, which makes it so that we will never have downtime during the updates. It also sets it so that we can only have a batch size of 4.

The UpdatePolicy section and the change to the InstanceType are the only differences between our templates. Now, select the Validate Template button. Once it's validated, select the Create Stack button at the top of the page to update the stack. On the Select Template page select Next. On the Specify Details page, we can not edit our name. Select Next, and then select Next again on the Options page. On the Review page, there is a section called Preview your changes. Here we can see what is being changed between our two stacks. Select Update.

Refresh the page. Our stack will show UPDATE_IN_PROGRESS. In the Events tab, in the bottom section of the page, we can see messages about the deletion of the old instances and updates to the new. Once the t2.micro instances are deleted and the t2.medium instances are running, our stack will read UPDATE_COMPLETE.

Use the Services dropdown and select EC2 under the Compute section. We find two t2.medium instances are running instead of the t2.micro. The t2.micro instances from before will read as "terminated."

Conclusion

In this lab we replaced our t2.micro instances with t2.mediums using rolling updates. This allowed us to do it without having any downtime. Congratulations on completing the lab!