Reference AMIs Using Systems Manager Parameters

 AWS Systems Manager | by Knoldus Inc. | Medium




Introduction

When you start an instance with the EC2 launch instance wizard in the Amazon EC2 console, you have the option to choose an AMI from the provided list or select a Systems Manager parameter that references an AMI ID (as explained in this section). If you utilize automation scripts to initiate your instances, you can indicate the Systems Manager parameter instead of the AMI ID.

A Systems Manager parameter is a key-value pair defined by the customer that can be created in the Systems Manager Parameter Store. The Parameter Store offers a centralized repository for externalizing your application configuration settings.

When a parameter that refers to an AMI ID is defined, make sure to indicate the data type as aws:ec2:image. This specification guarantees that when the parameter is created or updated, the value of the parameter is checked to confirm it is a valid AMI ID.

Use Case

Using Systems Manager parameters to reference AMI IDs makes it simpler for your users to choose the right AMI when starting instances. Additionally, Systems Manager parameters can streamline the upkeep of automation scripts.

Easier For Users

If you need instances to be launched with a particular AMI that is frequently updated, it is suggested to ask the users to choose a Systems Manager parameter to locate the AMI. By having them select a Systems Manager parameter, you can ensure that the most recent AMI is utilized for instance launches.

Simplify Automation Code Maintenance

If you use automation scripts to launch your instances, you can reference the Systems Manager parameter instead of the AMI ID. When a new version of the AMI is generated, you can update the AMI ID in the parameter to direct it to the latest version. This means that the automation scripts referencing the parameter don’t need to be altered every time a new AMI version is released. This approach streamlines the maintenance of the automation process and helps reduce deployment costs.

Permissions

If you use Systems Manager parameters that point to AMI IDs in the launch instance wizard, you must add the following permissions to your IAM policy:

  • ssm:DescribeParameters - Grants permission to view and select Systems Manager parameters.
  • ssm:GetParameters- Grants permission to retrieve the values of the Systems Manager parameters.

You can also restrict access to specific Systems Manager parameters.

Limitations

AMIs and Systems Manager parameters are specific to each Region. To utilize the same Systems Manager parameter name in different Regions, you must create a Systems Manager parameter with the identical name in each Region. In every Region, ensure the Systems Manager parameter is linked to an AMI located in that Region. Parameter names are sensitive to case. Backslashes for the parameter name are required only when the parameter is within a hierarchy. You can omit the backlash if the parameter is not part of a hierarchy. 

Conclusion

The reference AMIs using Systems Manager parameters are discussed. 









































Comments

Popular posts from this blog

Deployment (Part 3)

Deployment (Part 1)

Deployment (Part 2)