How do I launch ECS instances with Amazon ECS-optimized AMIs?
I want to launch instances with Amazon Machine Images (AMIs) optimized for Amazon Elastic Container Service (Amazon ECS). How can I do that?
"I want to launch instances with Amazon Machine Images (AMIs) optimized for Amazon Elastic Container Service (Amazon ECS). How can I do that?Short descriptionTo launch Amazon ECS-optimized AMIs, you can choose from the following options:Launch an Amazon ECS-optimized container instance with an Amazon ECS-optimized AMI from the Amazon Elastic Compute Cloud (Amazon EC2) consoleAutomate the creation of your Amazon ECS-optimized AMIsResolutionLaunch an Amazon ECS-optimized container instance with an Amazon ECS-optimized AMIOpen the Amazon EC2 console.In the Create Instance section, choose Launch Instance.From the left navigation pane, choose AWS Marketplace. 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 instance to join your Amazon ECS cluster, see Launching an Amazon ECS Linux container instance.Automate the creation of your Amazon ECS-optimized AMIsUse AWS 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 Amazon Linux EC2-optimized AMI version 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. You can also modify the command to return the machine image for a specific version and AWS Region.Important: To 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:AWSTemplateFormatVersion: '2010-09-09'Parameters:  ImageId:    Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>    Description: Use an Image from SSM Parameter Store    Default: /aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_idResources:  EC2Instance:    Type: AWS::EC2::Instance    Properties:      InstanceType: t3.micro      SecurityGroups: [!Ref 'EC2SecurityGroup']      ImageId: !Ref ImageId  EC2SecurityGroup:    Type: AWS::EC2::SecurityGroup    Properties:      GroupDescription: SSH access      SecurityGroupIngress:      - IpProtocol: tcp        FromPort: '22'        ToPort: '22'        CidrIp: 0.0.0.0/0Related informationAmazon Machine Images (AMI)Follow"