It is a best practice to use the latest version of the ECS-Optimized AMI when you create a new EC2 cluster for Amazon ECS, as new releases include bug fixes and feature updates. Previously, to ensure you were using the latest AMI meant checking the AWS Documentation or subscribing to the ECS-AMI SNS topic. You then had to manually update any templates or resources with the new AMI ID.
Now, you can simply query the SSM Parameter Store API to get the latest AMI version ID or a list of available AMI IDs and their corresponding Docker runtime and ECS agent versions. You can query the SSM Parameter Store API using the AWS CLI or any of the AWS SDKs.
To see the latest ECS Optimized Amazon Linux AMI information in your default region, run this AWS CLI command in your terminal:
aws ssm get-parameters –names /aws/service/ecs/optimized-ami/amazon-linux/recommended
Please visit the AWS region table to see all AWS regions where Amazon ECS is available.