How do I launch Amazon ECS-optimized AMIs?
Last updated: 2019-07-16
How do I launch Amazon Machine Images (AMIs) optimized for Amazon Elastic Container Service (Amazon ECS)?
Short Description
Choose one of the following options:
- Launch an Amazon ECS-Optimized container instance with an Amazon ECS-Optimized AMI
- Automate the creation of your Amazon ECS-Optimized AMIs
Resolution
Launch an Amazon ECS-Optimized container instance with an Amazon ECS-Optimized AMI
- Open the Amazon EC2 console.
- In the Create Instance section, choose Launch Instance.
- Choose AWS Marketplace, and then enter ecs-optimized in the search bar.
- Choose one of the following AMI versions based on your needs: Amazon Linux AMI, Amazon Linux 2 AMI, Windows Server 2016, or Amazon Linux 2 AMI (ARM).
Important: To get your Amazon ECS-optimized EC2 instance to join your Amazon ECS cluster, follow the steps at Launching an Amazon ECS Container Instance.
Automate the creation of your Amazon ECS-Optimized AMIs
Use Systems Manager parameters to automate and retrieve Amazon ECS-Optimized AMI metadata.
In the following example, the image_id sub-parameter returns the machine image AMI ID for only the current recommended version of the Amazon Linux ECS-Optimized AMI in us-east-1.
aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id --region us-east-1 --query "Parameters[0].Value"
You can use the AMI ID to launch your Amazon Linux container instance in us-east-1. Also, you can modify the command to return the machine image for a specific version and Region.
Important: To successfully use SSM parameters, run the most up-to-date version of the AWS Command Line Interface (AWS CLI).
You can use SSM parameters as input parameters for AWS CloudFormation templates. See the following example:
Parameters:
ImageId:
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
Details: Use an Image from SSM Parameter Store
Default: /aws/service/ecs/optimized-ami/amazon-linux-2/recommended
Did this article help you?
Anything we could improve?
Need more help?