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
posta un anno fa1508 visualizzazioni
2 Risposte
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.

ESPERTO
con risposta un anno fa
  • 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
con risposta un anno fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande