Chaning AMI and apply it to ASG for refresh old instacnes automatically, once I deploy

0

Hello, recently, I use Windows 2019 of EC2 instances and using launchconfigurations for AutoScaling.

I used own tool for deploy for ec2.

Is there anyway I can make AMI and apply to ASG and also exchanging old ec2 to new AMI image automatically?

I thought I could use 2 lambda to make it happend, but it didnt go well.

My scnerio is

deploy app -> API gateway -> lambda 1 ( making AMI) -> when the status chaged to 'available' -> trigger lambda 2 -> changing AMI image of ASG and refresh.

anyone have experience of this?

Heesu
asked a year ago1557 views
2 Answers
0

The way I've commonly seen it done is as follows.

ASG resources are defined in CloudFormation with rolling update of instances, and the template has an "AMI" parameter set to the ID of your custom AMI. When you want to update it to a new AMI ID, run a CloudFormation Stack update with the new value for the AMI parameter. You could trigger the Stack update as soon as your new AMI is available, or have something scheduled that regularly checks for new AMIs for Stacks that have an "AMI" parameter, for example.

BTW Launch Configurations are being deprecated, so best to update to using Launch Templates.

EXPERT
answered a year ago
  • Thank you for comment. first of all I know Launch Configuration will be deprecated but it will support until I have it, so I won't change yet.

    and you told me that I can use run cloudformation Stack update. However, I want to do all the process automatically.

    is it possible using cloudformation stack update as automation?

0

Does this automation template work for you? It uses launch templates instead of launch configs, but otherwise it sounds like what you're asking for: https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-walk-patch-windows-ami-autoscaling.html

AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions