Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

Tech

Finding public SSM parameters for AMIs with the EC2 DescribeImages API

Services like EC2 and ECS require an AMI ID at launch time, which pins the instance to a specific OS image. AMIs from AWS and its partners get patched often, and each patch ships as a new ID. If you hardcode that ID, it goes stale quickly and your infrastructure drifts behind the latest patches. The standard fix is to use a public SSM parameter — a well-known path that always resolves to the…

EC2 and ECS services need an AMI ID when launching instances, which locks the instance to a specific OS image. AMIs change frequently, so using a hardcoded ID causes infrastructure to become outdated quickly. The solution is to use a public SSM parameter that always points to the current AMI for a given family. However, finding the right parameter used to be a tedious process of navigating complex hierarchies and making multiple API calls.

Now, the EC2 DescribeImages API includes a PublicSsmParameterName field that tells you exactly which parameter maps to a given AMI. By retrieving this field, you can avoid manual searches and get the correct parameter name. When using the returned parameter name, add a leading slash to avoid validation errors when using it with Parameter Store.

You can then reference the parameter directly in your infrastructure code, such as in CloudFormation or CDK templates. This ensures you always use the latest AMI for your deployments without manually searching for the parameter each time.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 19 August →