Specifies the number of instances to launch and register to
the cluster.

Note

This parameter is only supported with tasks that use the
EC2 launch type.

Type: Integer

Default: 1

Required: No

--azs
availability_zone_1,availability_zone_2

Specifies a comma-separated list of two VPC Availability Zones
in which to create subnets (these zones must have the
available status). We recommend this option if
you do not specify a VPC ID with the --vpc option.

Warning

Leaving this option blank can result in a failure to
launch container instances when the randomly chosen zone is
unavailable.

Type: String

Required: No

--security-group
security_group_id[,security_group_id[,...]]

Specifies a comma-separated list of existing security groups
to associate with your container instances. If you do not
specify a security group here, then a new one is created.

For more information, see Security
Groups in the
Amazon EC2 User Guide for Linux Instances.

Required: No

--cidr ip_range

Specifies a CIDR/IP range for the security group to use for
container instances in your cluster.

Note

This parameter is ignored if an existing security group is
specified with the --security-group
option.

Type: CIDR/IP range

Default: 0.0.0.0/0

Required: No

--port
port_number

Specifies a port to open on the security group to use for
container instances in your cluster.

Note

This parameter is ignored if an existing security group is
specified with the --security-group
option.

Type: Integer

Default: 80

Required: No

--subnets
subnet_1,subnet_2

Specifies a comma-separated list of existing VPC subnet IDs in
which to launch your container instances.

Type: String

Required: This option is required if you specify a VPC with
the --vpc option.

--vpc vpc_id

Specifies the ID of an existing VPC in which to launch your
container instances. If you specify a VPC ID, you must specify a
list of existing subnets in that VPC with the
--subnets option. If you do not specify a VPC
ID, a new VPC is created with two subnets.

Type: String

Required: No

--extra-user-data
string

Specifies additional user data for your container instance.
Files can be shell scripts or cloud-init directives. They are
packaged into a MIME multipart archive along with user data
provided by the Amazon ECS CLI that directs instances to join your
cluster. For more information, see Specifying User Data.

Type: String

Required: No

--instance-type
instance_type

Specifies the EC2 instance type for your container
instances.

Note

This parameter is only supported with tasks that use the
EC2 launch type.

This parameter is only supported with tasks that use the
EC2 launch type.

Note

If an AMI ID is not specified, the Amazon ECS CLI
automatically retrieves the latest stable Amazon ECS-optimized AMI
by querying the SSM Parameter Store API during the cluster
resource creation process. This requires the user account
that you are using to have the required SSM permissions.
For more information, see Retrieving Amazon ECS-Optimized AMI
Metadata.

Specifies that an ECS cluster is created with no resources. If
other flags are also specified that would create resources, they
are ignored and a warning is displayed.

Required: No

--help, -h

Shows the help text for the specified command.

Required: No

Specifying User Data

When launching tasks that use the EC2 launch type, the ECS CLI
always creates container instances that include the following user data:

#!/bin/bash
echo ECS_CLUSTER={ clusterName } >> /etc/ecs/ecs.config

This user data directs the container instance to join your ECS cluster. You can
optionally include additional user data using the --extra-user-data
flag. The flag can be specified multiple times. For example, extra user data can be
shell scripts or cloud-init directives. For more information, see Running Commands on Your Linux Instance at
Launch in the Amazon EC2 User Guide for Linux Instances.

The Amazon ECS CLI takes the user data and packs it into a MIME multipart archive,
which can be used by cloud-init on the container instance. The Amazon ECS CLI allows
existing MIME multipart archives to be passed in with
--extra-user-data. The Amazon ECS CLI unpacks the existing archive, and then
repack it into the final archive (preserving all header and content type
information). The following is an example: