0

I have completely understood the concept of Auto-Scaling in AWS. My only question is, what AMI will the launch configuration use while in production environment?

According to my understanding Image of existing instance should be used. Lets say I have used an image of existing instance.

What if there are any changes in existing instance in future? In this scenario we have to update the AMI.

Is there any process to automate this process?

2 Answers2

2

When you create new AMI and set it in a new launch configuration (LC; LC can't be edited) or new version of a launch template (LT), then you will have to update the ASG configuration with the new LC/LT.

However, ASG by default will not update existing instances with new LC/LT. Only new instance that ASG launches will have the new LC/LT, and subsequently, the new AMI. Therefore, you will end up with ASG in which part of instances is running old AMI, and the other part is running new AMI.

You can deal with this in two commonly used ways:

  1. Create your LC/LT and ASG using CloudFormation and specify UpdatePolicy. The update policy will be triggered when LC/LT changes, and existing instances in ASG will be updated based on the rules you specify in the policy.

  2. Perform blue/green deployment of your ASG. How to perform the deployment is described and explained in details in an excellent AWS white paper:

Marcin
  • 215,873
  • 14
  • 235
  • 294
1

Auto scaling uses AMIs which are a point in time snapshot of your instance. Any changes made thereafter will not be applied to the AMI.

If you want any change to your base image you will need to recreate an image and roll it out across your Launch Configuration/Launch Template again.

There are many tools people use to provision the configuration of instances for AMIs such as Ansible, Chef and Puppet.

AWS also launched an automation tool for building images last year, the EC2 Image Builder

For some additional reading take a look at the golden ami pipeline.

Chris Williams
  • 32,215
  • 4
  • 30
  • 68
  • Cloudformation also has a built in rolling update feature so that if you make a new launch template version it will automatically deploy new instances in the ASG and the old ones will be terminated – Shahad Jun 13 '20 at 01:09