Consider the use case of deploying your current template in different regions. You would need to manually change
AmiID property in your template to match the AMI ID for each AWS Region. Similarly, if there is an update to the Amazon Machine Image, and you would like to use the latest image, the same manual process would apply.
To fix this, you can use the existing Parameters section of your CloudFormation template and define Systems Manager parameter type. A Systems Manager parameter type allows you to reference parameters held in the System Manager Parameter Store.
In this Lab, you will learn:
AmiID parameter to:
AmiID: Type: AWS::SSM::Parameter::ValueAWS::EC2::Image::Id Description: The ID of the AMI. Default: ‘/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2’
Go to the AWS console and update your stack with a new template.
01-lab06-SSM.yamland click Next.
Deploy the template in different AWS Region to the one you have been using.
Notice, that you did not have to update AMI ID parameter. By using CloudFormation’s integration with Systems Manager Parameter Store, your templates are now more generic and reusable.
Congratulations! You have now successfully updated your template to use the latest Amazon Linux AMI. Furthermore, your template can now be deployed in any region, without appending AMI ID parameter.