Cloudformation fetch image id

Viewed 528

I don't know, it 's possible or not. I have a ClodFormation template and I want to install my image from Marketplace. But there is a problen when I upload a new image, the image id changes. I want to do this automatically. I can fetch my image id as below the line.

So I want to ask, how can I do in CloudFormation template? Because there will be different zones.

aws ec2 describe-images  --filters Name=product-code,Values=$image_id Name=is-public,Values=true

Thanks for your answer.

1 Answers

This is a common use case and many customers store their respective AMI IDs using the AWS Systems Manager Parameter Store whenever there is a change. AWS CloudFormation provides an easy way to retrieve these.

This can also be used to automatically retrieve the correct AMIs in different AWS Regions or even different AWS accounts, as the CloudFormation stack will automatically retrieve the parameter local to the respective account and Region that it's deployed in.

Here's a post from the AWS Management & Governance Blog, describing how to integrate CloudFormation with Systems Manager Parameter Store.

Related