Creates a new Amazon ECS cluster. By default, your account receives a default
cluster when you launch your first container instance. However, you can create your own cluster with a unique name with the CreateCluster
action.
Note
When you call the CreateCluster API operation, Amazon ECS attempts to create the Amazon ECS service-linked role for your account so that required resources in other AWS services can be managed on your behalf. However, if the IAM user that makes the call does not have permissions to create the service-linked role, it is not created. For more information, see Using Service-Linked Roles for Amazon ECS in the Amazon Elastic Container Service Developer Guide .
See also: AWS API Documentation
See ‘aws help’ for descriptions of global parameters.
create-cluster
[--cluster-name <value>]
[--tags <value>]
[--settings <value>]
[--capacity-providers <value>]
[--default-capacity-provider-strategy <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
--cluster-name
(string)
The name of your cluster. If you do not specify a name for your cluster, you create a cluster named
default
. Up to 255 letters (uppercase and lowercase), numbers, and hyphens are allowed.
--tags
(list)
The metadata that you apply to the cluster to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define.
The following basic restrictions apply to tags:
Maximum number of tags per resource - 50
For each resource, each tag key must be unique, and each tag key can have only one value.
Maximum key length - 128 Unicode characters in UTF-8
Maximum value length - 256 Unicode characters in UTF-8
If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.
Tag keys and values are case-sensitive.
Do not use
aws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.(structure)
The metadata that you apply to a resource to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define.
The following basic restrictions apply to tags:
Maximum number of tags per resource - 50
For each resource, each tag key must be unique, and each tag key can have only one value.
Maximum key length - 128 Unicode characters in UTF-8
Maximum value length - 256 Unicode characters in UTF-8
If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.
Tag keys and values are case-sensitive.
Do not use
aws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.key -> (string)
One part of a key-value pair that make up a tag. A
key
is a general label that acts like a category for more specific tag values.value -> (string)
The optional part of a key-value pair that make up a tag. A
value
acts as a descriptor within a tag category (key).
Shorthand Syntax:
key=string,value=string ...
JSON Syntax:
[
{
"key": "string",
"value": "string"
}
...
]
--settings
(list)
The setting to use when creating a cluster. This parameter is used to enable CloudWatch Container Insights for a cluster. If this value is specified, it will override the
containerInsights
value set with PutAccountSetting or PutAccountSettingDefault .(structure)
The settings to use when creating a cluster. This parameter is used to enable CloudWatch Container Insights for a cluster.
name -> (string)
The name of the cluster setting. The only supported value is
containerInsights
.value -> (string)
The value to set for the cluster setting. The supported values are
enabled
anddisabled
. Ifenabled
is specified, CloudWatch Container Insights will be enabled for the cluster, otherwise it will be disabled unless thecontainerInsights
account setting is enabled. If a cluster value is specified, it will override thecontainerInsights
value set with PutAccountSetting or PutAccountSettingDefault .
Shorthand Syntax:
name=string,value=string ...
JSON Syntax:
[
{
"name": "containerInsights",
"value": "string"
}
...
]
--capacity-providers
(list)
The short name of one or more capacity providers to associate with the cluster.
If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created and not already associated with another cluster. New capacity providers can be created with the CreateCapacityProvider API operation.
To use a AWS Fargate capacity provider, specify either the
FARGATE
orFARGATE_SPOT
capacity providers. The AWS Fargate capacity providers are available to all accounts and only need to be associated with a cluster to be used.The PutClusterCapacityProviders API operation is used to update the list of available capacity providers for a cluster after the cluster is created.
(string)
Syntax:
"string" "string" ...
--default-capacity-provider-strategy
(list)
The capacity provider strategy to use by default for the cluster.
When creating a service or running a task on a cluster, if no capacity provider or launch type is specified then the default capacity provider strategy for the cluster is used.
A capacity provider strategy consists of one or more capacity providers along with the
base
andweight
to assign to them. A capacity provider must be associated with the cluster to be used in a capacity provider strategy. The PutClusterCapacityProviders API is used to associate a capacity provider with a cluster. Only capacity providers with anACTIVE
orUPDATING
status can be used.If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created. New capacity providers can be created with the CreateCapacityProvider API operation.
To use a AWS Fargate capacity provider, specify either the
FARGATE
orFARGATE_SPOT
capacity providers. The AWS Fargate capacity providers are available to all accounts and only need to be associated with a cluster to be used.If a default capacity provider strategy is not defined for a cluster during creation, it can be defined later with the PutClusterCapacityProviders API operation.
(structure)
The details of a capacity provider strategy.
capacityProvider -> (string)
The short name of the capacity provider.
weight -> (integer)
The weight value designates the relative percentage of the total number of tasks launched that should use the specified capacity provider.
For example, if you have a strategy that contains two capacity providers and both have a weight of
1
, then when thebase
is satisfied, the tasks will be split evenly across the two capacity providers. Using that same logic, if you specify a weight of1
for capacityProviderA and a weight of4
for capacityProviderB , then for every one task that is run using capacityProviderA , four tasks would use capacityProviderB .base -> (integer)
The base value designates how many tasks, at a minimum, to run on the specified capacity provider. Only one capacity provider in a capacity provider strategy can have a base defined.
Shorthand Syntax:
capacityProvider=string,weight=integer,base=integer ...
JSON Syntax:
[
{
"capacityProvider": "string",
"weight": integer,
"base": integer
}
...
]
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
See ‘aws help’ for descriptions of global parameters.
Example 1: To create a new cluster
The following create-cluster
example creates a cluster.
aws ecs create-cluster \
--cluster-name MyCluster
Output:
{
"cluster": {
"clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/MyCluster",
"clusterName": "MyCluster",
"status": "ACTIVE",
"registeredContainerInstancesCount": 0,
"pendingTasksCount": 0,
"runningTasksCount": 0,
"activeServicesCount": 0,
"statistics": [],
"tags": []
}
}
For more information, see Creating a Cluster in the Amazon ECS Developer Guide.
Example 2: To create a new cluster using capacity providers
The following create-cluster
example creates a cluster and associates two existing capacity providers with it. The create-capacity-provider
command is used to create a capacity provider. Specifying a default capacity provider strategy is optional, but recommended. In this example, we create a cluster named MyCluster
and associate the MyCapacityProvider1
and MyCapacityProvider2
capacity providers with it. A default capacity provider strategy is specified that spreads the tasks evenly across both capacity providers.
- aws ecs create-cluster
–cluster-name MyCluster –capacity-providers MyCapacityProvider1 MyCapacityProvider2 –default-capacity-provider-strategy capacityProvider=MyCapacityProvider1,weight=1 capacityProvider=MyCapacityProvider2,weight=1
Output:
{
"cluster": {
"clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/MyCluster",
"clusterName": "MyCluster",
"status": "PROVISIONING",
"registeredContainerInstancesCount": 0,
"pendingTasksCount": 0,
"runningTasksCount": 0,
"activeServicesCount": 0,
"statistics": [],
"settings": [
{
"name": "containerInsights",
"value": "enabled"
}
],
"capacityProviders": [
"MyCapacityProvider1",
"MyCapacityProvider2"
],
"defaultCapacityProviderStrategy": [
{
"capacityProvider": "MyCapacityProvider1",
"weight": 1,
"base": 0
},
{
"capacityProvider": "MyCapacityProvider2",
"weight": 1,
"base": 0
}
],
"attachments": [
{
"id": "0fb0c8f4-6edd-4de1-9b09-17e470ee1918",
"type": "asp",
"status": "PRECREATED",
"details": [
{
"name": "capacityProviderName",
"value": "MyCapacityProvider1"
},
{
"name": "scalingPlanName",
"value": "ECSManagedAutoScalingPlan-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
]
},
{
"id": "ae592060-2382-4663-9476-b015c685593c",
"type": "asp",
"status": "PRECREATED",
"details": [
{
"name": "capacityProviderName",
"value": "MyCapacityProvider2"
},
{
"name": "scalingPlanName",
"value": "ECSManagedAutoScalingPlan-a1b2c3d4-5678-90ab-cdef-EXAMPLE22222"
}
]
}
],
"attachmentsStatus": "UPDATE_IN_PROGRESS"
}
}
For more information, see Cluster capacity providers in the Amazon ECS Developer Guide.
Example 3: To create a new cluster with multiple tags
The following create-cluster
example creates a cluster with multiple tags. For more information about adding tags using shorthand syntax, see Using Shorthand Syntax with the AWS Command Line Interface in the AWS CLI User Guide.
aws ecs create-cluster \
--cluster-name MyCluster \
--tags key=key1,value=value1 key=key2,value=value2 key=key3,value=value3
Output:
{
"cluster": {
"clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/MyCluster",
"clusterName": "MyCluster",
"status": "ACTIVE",
"registeredContainerInstancesCount": 0,
"pendingTasksCount": 0,
"runningTasksCount": 0,
"activeServicesCount": 0,
"statistics": [],
"tags": [
{
"key": "key1",
"value": "value1"
},
{
"key": "key2",
"value": "value2"
},
{
"key": "key3",
"value": "value3"
}
]
}
}
For more information, see Creating a Cluster in the Amazon ECS Developer Guide.
cluster -> (structure)
The full description of your new cluster.
clusterArn -> (string)
The Amazon Resource Name (ARN) that identifies the cluster. The ARN contains the
arn:aws:ecs
namespace, followed by the Region of the cluster, the AWS account ID of the cluster owner, thecluster
namespace, and then the cluster name. For example,arn:aws:ecs:region:012345678910:cluster/test
.clusterName -> (string)
A user-generated string that you use to identify your cluster.
status -> (string)
The status of the cluster. The following are the possible states that will be returned.
ACTIVE
The cluster is ready to accept tasks and if applicable you can register container instances with the cluster.
PROVISIONING
The cluster has capacity providers associated with it and the resources needed for the capacity provider are being created.
DEPROVISIONING
The cluster has capacity providers associated with it and the resources needed for the capacity provider are being deleted.
FAILED
The cluster has capacity providers associated with it and the resources needed for the capacity provider have failed to create.
INACTIVE
The cluster has been deleted. Clusters with an
INACTIVE
status may remain discoverable in your account for a period of time. However, this behavior is subject to change in the future, so you should not rely onINACTIVE
clusters persisting.registeredContainerInstancesCount -> (integer)
The number of container instances registered into the cluster. This includes container instances in both
ACTIVE
andDRAINING
status.runningTasksCount -> (integer)
The number of tasks in the cluster that are in the
RUNNING
state.pendingTasksCount -> (integer)
The number of tasks in the cluster that are in the
PENDING
state.activeServicesCount -> (integer)
The number of services that are running on the cluster in an
ACTIVE
state. You can view these services with ListServices .statistics -> (list)
Additional information about your clusters that are separated by launch type, including:
runningEC2TasksCount
RunningFargateTasksCount
pendingEC2TasksCount
pendingFargateTasksCount
activeEC2ServiceCount
activeFargateServiceCount
drainingEC2ServiceCount
drainingFargateServiceCount
(structure)
A key-value pair object.
name -> (string)
The name of the key-value pair. For environment variables, this is the name of the environment variable.
value -> (string)
The value of the key-value pair. For environment variables, this is the value of the environment variable.
tags -> (list)
The metadata that you apply to the cluster to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define.
The following basic restrictions apply to tags:
Maximum number of tags per resource - 50
For each resource, each tag key must be unique, and each tag key can have only one value.
Maximum key length - 128 Unicode characters in UTF-8
Maximum value length - 256 Unicode characters in UTF-8
If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.
Tag keys and values are case-sensitive.
Do not use
aws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.(structure)
The metadata that you apply to a resource to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define.
The following basic restrictions apply to tags:
Maximum number of tags per resource - 50
For each resource, each tag key must be unique, and each tag key can have only one value.
Maximum key length - 128 Unicode characters in UTF-8
Maximum value length - 256 Unicode characters in UTF-8
If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.
Tag keys and values are case-sensitive.
Do not use
aws:
,AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.key -> (string)
One part of a key-value pair that make up a tag. A
key
is a general label that acts like a category for more specific tag values.value -> (string)
The optional part of a key-value pair that make up a tag. A
value
acts as a descriptor within a tag category (key).settings -> (list)
The settings for the cluster. This parameter indicates whether CloudWatch Container Insights is enabled or disabled for a cluster.
(structure)
The settings to use when creating a cluster. This parameter is used to enable CloudWatch Container Insights for a cluster.
name -> (string)
The name of the cluster setting. The only supported value is
containerInsights
.value -> (string)
The value to set for the cluster setting. The supported values are
enabled
anddisabled
. Ifenabled
is specified, CloudWatch Container Insights will be enabled for the cluster, otherwise it will be disabled unless thecontainerInsights
account setting is enabled. If a cluster value is specified, it will override thecontainerInsights
value set with PutAccountSetting or PutAccountSettingDefault .capacityProviders -> (list)
The capacity providers associated with the cluster.
(string)
defaultCapacityProviderStrategy -> (list)
The default capacity provider strategy for the cluster. When services or tasks are run in the cluster with no launch type or capacity provider strategy specified, the default capacity provider strategy is used.
(structure)
The details of a capacity provider strategy.
capacityProvider -> (string)
The short name of the capacity provider.
weight -> (integer)
The weight value designates the relative percentage of the total number of tasks launched that should use the specified capacity provider.
For example, if you have a strategy that contains two capacity providers and both have a weight of
1
, then when thebase
is satisfied, the tasks will be split evenly across the two capacity providers. Using that same logic, if you specify a weight of1
for capacityProviderA and a weight of4
for capacityProviderB , then for every one task that is run using capacityProviderA , four tasks would use capacityProviderB .base -> (integer)
The base value designates how many tasks, at a minimum, to run on the specified capacity provider. Only one capacity provider in a capacity provider strategy can have a base defined.
attachments -> (list)
The resources attached to a cluster. When using a capacity provider with a cluster, the Auto Scaling plan that is created will be returned as a cluster attachment.
(structure)
An object representing a container instance or task attachment.
id -> (string)
The unique identifier for the attachment.
type -> (string)
The type of the attachment, such as
ElasticNetworkInterface
.status -> (string)
The status of the attachment. Valid values are
PRECREATED
,CREATED
,ATTACHING
,ATTACHED
,DETACHING
,DETACHED
, andDELETED
.details -> (list)
Details of the attachment. For elastic network interfaces, this includes the network interface ID, the MAC address, the subnet ID, and the private IPv4 address.
(structure)
A key-value pair object.
name -> (string)
The name of the key-value pair. For environment variables, this is the name of the environment variable.
value -> (string)
The value of the key-value pair. For environment variables, this is the value of the environment variable.
attachmentsStatus -> (string)
The status of the capacity providers associated with the cluster. The following are the states that will be returned:
UPDATE_IN_PROGRESS
The available capacity providers for the cluster are updating. This occurs when the Auto Scaling plan is provisioning or deprovisioning.
UPDATE_COMPLETE
The capacity providers have successfully updated.
UPDATE_FAILED
The capacity provider updates failed.