Launching an Amazon ECS Container Instance
You can launch an Amazon ECS container instance using the AWS Management Console, as described in this topic. Before you begin, be sure that you've completed the steps in Setting Up with Amazon ECS. After you've launched your instance, you can use it to run tasks.
To launch a container instance
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
From the navigation bar, select the region to use.
Amazon ECS is available in the following regions:
Region Name Region US East (N. Virginia) us-east-1 US East (Ohio) us-east-2 US West (N. California) us-west-1 US West (Oregon) us-west-2 EU (Ireland) eu-west-1 EU (Frankfurt) eu-central-1 Asia Pacific (Tokyo) ap-northeast-1 Asia Pacific (Singapore) ap-southeast-1 Asia Pacific (Sydney) ap-southeast-2
From the console dashboard, choose Launch Instance.
On the Choose an Amazon Machine Image (AMI) page, choose Community AMIs.
Choose an AMI for your container instance. You can choose the Amazon ECS-optimized AMI, or another operating system, such as CoreOS or Ubuntu. If you do not choose the Amazon ECS-optimized AMI, you need to follow the procedures in Installing the Amazon ECS Container Agent.
For Amazon ECS-specific CoreOS installation instructions, see https://coreos.com/docs/running-coreos/cloud-providers/ecs/.
To use the Amazon ECS-optimized AMI, type amazon-ecs-optimized in the Search community AMIs field and press the Enter key. Choose Select next to the amzn-ami-2016.03.j-amazon-ecs-optimized AMI. The current Amazon ECS-optimized AMI IDs by region are listed below for reference.
Region AMI ID
On the Choose an Instance Type page, you can select the hardware configuration of your instance. The
t2.microinstance type is selected by default. The instance type that you select determines the resources available for your tasks to run on.
Choose Next: Configure Instance Details.
On the Configure Instance Details page, set the Auto-assign Public IP field depending on whether or not you want your instance to be accessible from the public Internet. If your instance should be accessible from the Internet, verify that the Auto-assign Public IP field is set to Enable. If your instance should not be accessible from the Internet, set this field to Disable.
Container instances need external network access to communicate with the Amazon ECS service endpoint, so if your container instances do not have public IP addresses, then they must use network address translation (NAT) or an HTTP proxy to provide this access. For more information, see NAT Instances in the Amazon VPC User Guide and HTTP Proxy Configuration in this guide.
On the Configure Instance Details page, select the
ecsInstanceRoleIAM role value that you created for your container instances in Setting Up with Amazon ECS.
If you do not launch your container instance with the proper IAM permissions, your Amazon ECS agent will not connect to your cluster. For more information, see Amazon ECS Container Instance IAM Role.
(Optional) Configure your Amazon ECS container instance with user data, such as the agent environment variables from Amazon ECS Container Agent Configuration; Amazon EC2 user data scripts are executed only once, when the instance is first launched.
By default, your container instance launches into your default cluster. If you want to launch into your own cluster instead of the default, choose the Advanced Details list and paste the following script into the User data field, replacing
your_cluster_namewith the name of your cluster.
#!/bin/bash echo ECS_CLUSTER=
Or, if you have an
ecs.configfile in Amazon S3 and have enabled Amazon S3 read-only access to your container instance role, choose the Advanced Details list and paste the following script into the User data field, replacing
your_bucket_namewith the name of your bucket to install the AWS CLI and write your configuration file at launch time.
For more information about this configuration, see Storing Container Instance Configuration in Amazon S3.
#!/bin/bash yum install -y aws-cli aws s3 cp s3://
Choose Next: Add Storage.
On the Add Storage page, configure the storage for your container instance.
If you are using an Amazon ECS-optimized AMI prior to the 2015.09.d version, your instance has a single volume that is shared by the operating system and Docker.
If you are using the 2015.09.d or later Amazon ECS-optimized AMI, your instance has two volumes configured. The Root volume is for the operating system's use, and the second Amazon EBS volume (attached to
/dev/xvdcz) is for Docker's use.
You can optionally increase or decrease the volume sizes for your instance to meet your application needs.
Choose Review and Launch.
On the Review Instance Launch page, under Security Groups, you'll see that the wizard created and selected a security group for you. Instead, select the security group that you created in Setting Up with Amazon ECS using the following steps:
Choose Edit security groups.
On the Configure Security Group page, ensure that the Select an existing security group option is selected.
Select the security group you created for your container instance from the list of existing security groups, and choose Review and Launch.
On the Review Instance Launch page, choose Launch.
In the Select an existing key pair or create a new key pair dialog box, choose Choose an existing key pair, then select the key pair that you created when getting set up.
When you are ready, select the acknowledgment field, and then choose Launch Instances.
A confirmation page lets you know that your instance is launching. Choose View Instances to close the confirmation page and return to the console.
On the Instances screen, you can view the status of your instance. It takes a short time for an instance to launch. When you launch an instance, its initial state is
pending. After the instance starts, its state changes to
running, and it receives a public DNS name. (If the Public DNS column is hidden, choose the Show/Hide icon and select Public DNS.)