Updating AWS Autoscaling Launch Configs with a new AMI using Lambda
08 Dec 2017 - Aaron Dodd
Amazon provides a great article1 on using Lambda to automate updating the AMI of an auto scaling group’s launch configuration. The only problem with their provided code is that the existing launch configuration’s storage settings (ebs volumes) are not kept, so the new launch config has no disks specified, resulting in new launches using the AMI’s default settings.
Since an AMI may be generic, the storage settings may be specific to different use cases.
I took their example code and altered it slightly. In the version below, there is an additional lookup for the existing root volume information, which is then applied to the newly generated launch config. My change only looks for the root volume since that fits my use-case, but someone smart can adjust to loop through and keep all storage assignments, if needed.