start-task
Description
Starts a new task from the specified task definition on the specified container instance or instances.
Note
On March 21, 2024, a change was made to resolve the task definition revision before authorization. When a task definition revision is not specified, authorization will occur using the latest revision of a task definition.Note
Amazon Elastic Inference (EI) is no longer available to customers.Alternatively, you can use``RunTask`` to place tasks for you. For more information, see Scheduling Tasks in the Amazon Elastic Container Service Developer Guide .
You can attach Amazon EBS volumes to Amazon ECS tasks by configuring the volume when creating or updating a service. For more infomation, see Amazon EBS volumes in the Amazon Elastic Container Service Developer Guide .
See also: AWS API Documentation
Synopsis
start-task
[--cluster <value>]
--container-instances <value>
[--enable-ecs-managed-tags | --no-enable-ecs-managed-tags]
[--enable-execute-command | --disable-execute-command]
[--group <value>]
[--network-configuration <value>]
[--overrides <value>]
[--propagate-tags <value>]
[--reference-id <value>]
[--started-by <value>]
[--tags <value>]
--task-definition <value>
[--volume-configurations <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]
Options
--cluster (string)
--container-instances (list)
The container instance IDs or full ARN entries for the container instances where you would like to place your task. You can specify up to 10 container instances.
(string)
Syntax:
"string" "string" ...
--enable-ecs-managed-tags | --no-enable-ecs-managed-tags (boolean)
--enable-execute-command | --disable-execute-command (boolean)
true , this turns on the execute command functionality on all containers in the task.--group (string)
--network-configuration (structure)
The VPC subnet and security group configuration for tasks that receive their own elastic network interface by using the awsvpc networking mode.
awsvpcConfiguration -> (structure)
The VPC subnets and security groups that are associated with a task.
Note
All specified subnets and security groups must be from the same VPC.subnets -> (list)
The IDs of the subnets associated with the task or service. There’s a limit of 16 subnets that can be specified.
Note
All specified subnets must be from the same VPC.(string)
securityGroups -> (list)
The IDs of the security groups associated with the task or service. If you don’t specify a security group, the default security group for the VPC is used. There’s a limit of 5 security groups that can be specified.
Note
All specified security groups must be from the same VPC.(string)
assignPublicIp -> (string)
Whether the task’s elastic network interface receives a public IP address.
Consider the following when you set this value:
- When you use
create-serviceorupdate-service, the default isDISABLED. - When the service
deploymentControllerisECS, the value must beDISABLED.
Shorthand Syntax:
awsvpcConfiguration={subnets=[string,string],securityGroups=[string,string],assignPublicIp=string}
JSON Syntax:
{
"awsvpcConfiguration": {
"subnets": ["string", ...],
"securityGroups": ["string", ...],
"assignPublicIp": "ENABLED"|"DISABLED"
}
}
--overrides (structure)
A list of container overrides in JSON format that specify the name of a container in the specified task definition and the overrides it receives. You can override the default command for a container (that’s specified in the task definition or Docker image) with a command override. You can also override existing environment variables (that are specified in the task definition or Docker image) on a container or add new environment variables to it with an environment override.
Note
A total of 8192 characters are allowed for overrides. This limit includes the JSON formatting characters of the override structure.containerOverrides -> (list)
One or more container overrides that are sent to a task.
(structure)
The overrides that are sent to a container. An empty container override can be passed in. An example of an empty container override is {"containerOverrides": [ ] } . If a non-empty container override is specified, the name parameter must be included.
You can use Secrets Manager or Amazon Web Services Systems Manager Parameter Store to store the sensitive data. For more information, see Retrieve secrets through environment variables in the Amazon ECS Developer Guide.
name -> (string)
command -> (list)
The command to send to the container that overrides the default command from the Docker image or the task definition. You must also specify a container name.
(string)
environment -> (list)
The environment variables to send to the container. You can add new environment variables, which are added to the container at launch, or you can override the existing environment variables from the Docker image or the task definition. You must also specify a container name.
(structure)
A key-value pair object.
name -> (string)
value -> (string)
environmentFiles -> (list)
A list of files containing the environment variables to pass to a container, instead of the value from the container definition.
(structure)
A list of files containing the environment variables to pass to a container. You can specify up to ten environment files. The file must have a .env file extension. Each line in an environment file should contain an environment variable in VARIABLE=VALUE format. Lines beginning with # are treated as comments and are ignored.
If there are environment variables specified using the environment parameter in a container definition, they take precedence over the variables contained within an environment file. If multiple environment files are specified that contain the same variable, they’re processed from the top down. We recommend that you use unique variable names. For more information, see Use a file to pass environment variables to a container in the Amazon Elastic Container Service Developer Guide .
Environment variable files are objects in Amazon S3 and all Amazon S3 security considerations apply.
You must use the following platforms for the Fargate launch type:
- Linux platform version
1.4.0or later. - Windows platform version
1.0.0or later.
Consider the following when using the Fargate launch type:
- The file is handled like a native Docker env-file.
- There is no support for shell escape handling.
- The container entry point interperts the
VARIABLEvalues.
value -> (string)
type -> (string)
s3 .cpu -> (integer)
cpu units reserved for the container, instead of the default value from the task definition. You must also specify a container name.memory -> (integer)
memoryReservation -> (integer)
resourceRequirements -> (list)
The type and amount of a resource to assign to a container, instead of the default value from the task definition. The only supported resource is a GPU.
(structure)
The type and amount of a resource to assign to a container. The supported resource types are GPUs and Elastic Inference accelerators. For more information, see Working with GPUs on Amazon ECS or Working with Amazon Elastic Inference on Amazon ECS in the Amazon Elastic Container Service Developer Guide
value -> (string)
The value for the specified resource type.
When the type is GPU , the value is the number of physical GPUs the Amazon ECS container agent reserves for the container. The number of GPUs that’s reserved for all containers in a task can’t exceed the number of available GPUs on the container instance that the task is launched on.
When the type is InferenceAccelerator , the value matches the deviceName for an InferenceAccelerator specified in a task definition.
type -> (string)
cpu -> (string)
inferenceAcceleratorOverrides -> (list)
The Elastic Inference accelerator override for the task.
(structure)
Details on an Elastic Inference accelerator task override. This parameter is used to override the Elastic Inference accelerator specified in the task definition. For more information, see Working with Amazon Elastic Inference on Amazon ECS in the Amazon Elastic Container Service Developer Guide .
deviceName -> (string)
deviceName specified in the task definition.deviceType -> (string)
executionRoleArn -> (string)
memory -> (string)
taskRoleArn -> (string)
ephemeralStorage -> (structure)
The ephemeral storage setting override for the task.
Note
This parameter is only supported for tasks hosted on Fargate that use the following platform versions:
- Linux platform version
1.4.0or later. - Windows platform version
1.0.0or later.
sizeInGiB -> (integer)
21 GiB and the maximum supported value is 200 GiB.JSON Syntax:
{
"containerOverrides": [
{
"name": "string",
"command": ["string", ...],
"environment": [
{
"name": "string",
"value": "string"
}
...
],
"environmentFiles": [
{
"value": "string",
"type": "s3"
}
...
],
"cpu": integer,
"memory": integer,
"memoryReservation": integer,
"resourceRequirements": [
{
"value": "string",
"type": "GPU"|"InferenceAccelerator"
}
...
]
}
...
],
"cpu": "string",
"inferenceAcceleratorOverrides": [
{
"deviceName": "string",
"deviceType": "string"
}
...
],
"executionRoleArn": "string",
"memory": "string",
"taskRoleArn": "string",
"ephemeralStorage": {
"sizeInGiB": integer
}
}
--propagate-tags (string)
Specifies whether to propagate the tags from the task definition or the service to the task. If no value is specified, the tags aren’t propagated.
Possible values:
TASK_DEFINITIONSERVICENONE
--reference-id (string)
--started-by (string)
An optional tag specified when a task is started. For example, if you automatically trigger a task to run a batch process job, you could apply a unique identifier for that job to your task with the startedBy parameter. You can then identify which tasks belong to that job by filtering the results of a ListTasks call with the startedBy value. Up to 36 letters (uppercase and lowercase), numbers, hyphens (-), forward slash (/), and underscores (_) are allowed.
If a task is started by an Amazon ECS service, the startedBy parameter contains the deployment ID of the service that starts it.
--tags (list)
The metadata that you apply to the task 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 Amazon Web Services 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. You define them.
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 Amazon Web Services 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)
key is a general label that acts like a category for more specific tag values.value -> (string)
value acts as a descriptor within a tag category (key).Shorthand Syntax:
key=string,value=string ...
JSON Syntax:
[
{
"key": "string",
"value": "string"
}
...
]
--task-definition (string)
family and revision (family:revision ) or full ARN of the task definition to start. If a revision isn’t specified, the latest ACTIVE revision is used.--volume-configurations (list)
The details of the volume that was configuredAtLaunch . You can configure the size, volumeType, IOPS, throughput, snapshot and encryption in TaskManagedEBSVolumeConfiguration . The name of the volume must match the name from the task definition.
(structure)
Configuration settings for the task volume that was configuredAtLaunch that weren’t set during RegisterTaskDef .
name -> (string)
Volume object in the task definition.managedEBSVolume -> (structure)
The configuration for the Amazon EBS volume that Amazon ECS creates and manages on your behalf. These settings are used to create each Amazon EBS volume, with one volume created for each task. The Amazon EBS volumes are visible in your account in the Amazon EC2 console once they are created.
encrypted -> (boolean)
false , the setting is overridden and the volume is encrypted with the KMS key specified for Amazon EBS encryption by default. This parameter maps 1:1 with the Encrypted parameter of the CreateVolume API in the Amazon EC2 API Reference .kmsKeyId -> (string)
The Amazon Resource Name (ARN) identifier of the Amazon Web Services Key Management Service key to use for Amazon EBS encryption. When a key is specified using this parameter, it overrides Amazon EBS default encryption or any KMS key that you specified for cluster-level managed storage encryption. This parameter maps 1:1 with the KmsKeyId parameter of the CreateVolume API in the Amazon EC2 API Reference . For more information about encrypting Amazon EBS volumes attached to a task, see Encrypt data stored in Amazon EBS volumes attached to Amazon ECS tasks .
Warning
Amazon Web Services authenticates the Amazon Web Services Key Management Service key asynchronously. Therefore, if you specify an ID, alias, or ARN that is invalid, the action can appear to complete, but eventually fails.volumeType -> (string)
The volume type. This parameter maps 1:1 with the VolumeType parameter of the CreateVolume API in the Amazon EC2 API Reference . For more information, see Amazon EBS volume types in the Amazon EC2 User Guide .
The following are the supported volume types.
- General Purpose SSD:
gp2|gp3 - Provisioned IOPS SSD:
io1|io2 - Throughput Optimized HDD:
st1 - Cold HDD:
sc1 - Magnetic:
standard
Note
The magnetic volume type is not supported on Fargate.sizeInGiB -> (integer)
The size of the volume in GiB. You must specify either a volume size or a snapshot ID. If you specify a snapshot ID, the snapshot size is used for the volume size by default. You can optionally specify a volume size greater than or equal to the snapshot size. This parameter maps 1:1 with the Size parameter of the CreateVolume API in the Amazon EC2 API Reference .
The following are the supported volume size values for each volume type.
-
gp2andgp3: 1-16,384 -
io1andio2: 4-16,384 -
st1andsc1: 125-16,384 -
standard: 1-1,024
snapshotId -> (string)
SnapshotId parameter of the CreateVolume API in the Amazon EC2 API Reference .volumeInitializationRate -> (integer)
snapshotId . For more information, see Initialize Amazon EBS volumes in the Amazon EBS User Guide .iops -> (integer)
The number of I/O operations per second (IOPS). For gp3 , io1 , and io2 volumes, this represents the number of IOPS that are provisioned for the volume. For gp2 volumes, this represents the baseline performance of the volume and the rate at which the volume accumulates I/O credits for bursting.
The following are the supported values for each volume type.
-
gp3: 3,000 - 16,000 IOPS -
io1: 100 - 64,000 IOPS -
io2: 100 - 256,000 IOPS
This parameter is required for io1 and io2 volume types. The default for gp3 volumes is 3,000 IOPS . This parameter is not supported for st1 , sc1 , or standard volume types.
This parameter maps 1:1 with the Iops parameter of the CreateVolume API in the Amazon EC2 API Reference .
throughput -> (integer)
The throughput to provision for a volume, in MiB/s, with a maximum of 1,000 MiB/s. This parameter maps 1:1 with the Throughput parameter of the CreateVolume API in the Amazon EC2 API Reference .
Warning
This parameter is only supported for thegp3 volume type.tagSpecifications -> (list)
The tags to apply to the volume. Amazon ECS applies service-managed tags by default. This parameter maps 1:1 with the TagSpecifications.N parameter of the CreateVolume API in the Amazon EC2 API Reference .
(structure)
The tag specifications of an Amazon EBS volume.
resourceType -> (string)
tags -> (list)
The tags applied to this Amazon EBS volume. AmazonECSCreated and AmazonECSManaged are reserved tags that can’t be used.
(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. You define them.
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 Amazon Web Services 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)
key is a general label that acts like a category for more specific tag values.value -> (string)
value acts as a descriptor within a tag category (key).propagateTags -> (string)
SERVICE specified in ServiceVolumeConfiguration . If no value is specified, the tags aren’t propagated.roleArn -> (string)
AmazonECSInfrastructureRolePolicyForVolumes IAM policy with this role. For more information, see Amazon ECS infrastructure IAM role in the Amazon ECS Developer Guide .terminationPolicy -> (structure)
The termination policy for the volume when the task exits. This provides a way to control whether Amazon ECS terminates the Amazon EBS volume when the task stops.
deleteOnTermination -> (boolean)
true is specified, Amazon ECS deletes the Amazon EBS volume on your behalf when the task goes into the STOPPED state. If no value is specified, the default value is true is used. When set to false , Amazon ECS leaves the volume in your account.filesystemType -> (string)
The Linux filesystem type for the volume. For volumes created from a snapshot, you must specify the same filesystem type that the volume was using when the snapshot was created. If there is a filesystem type mismatch, the task will fail to start.
The available filesystem types are ext3 , ext4 , and xfs . If no value is specified, the xfs filesystem type is used by default.
JSON Syntax:
[
{
"name": "string",
"managedEBSVolume": {
"encrypted": true|false,
"kmsKeyId": "string",
"volumeType": "string",
"sizeInGiB": integer,
"snapshotId": "string",
"volumeInitializationRate": integer,
"iops": integer,
"throughput": integer,
"tagSpecifications": [
{
"resourceType": "volume",
"tags": [
{
"key": "string",
"value": "string"
}
...
],
"propagateTags": "TASK_DEFINITION"|"SERVICE"|"NONE"
}
...
],
"roleArn": "string",
"terminationPolicy": {
"deleteOnTermination": true|false
},
"filesystemType": "ext3"|"ext4"|"xfs"|"ntfs"
}
}
...
]
--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. The generated JSON skeleton is not stable between versions of the AWS CLI and there are no backwards compatibility guarantees in the JSON skeleton generated.
Global Options
--debug (boolean)
Turn on debug logging.
--endpoint-url (string)
Override command’s default URL with the given URL.
--no-verify-ssl (boolean)
By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.
--no-paginate (boolean)
Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.
--output (string)
The formatting style for command output.
- json
- text
- table
- yaml
- yaml-stream
--query (string)
A JMESPath query to use in filtering the response data.
--profile (string)
Use a specific profile from your credential file.
--region (string)
The region to use. Overrides config/env settings.
--version (string)
Display the version of this tool.
--color (string)
Turn on/off color output.
- on
- off
- auto
--no-sign-request (boolean)
Do not sign requests. Credentials will not be loaded if this argument is provided.
--ca-bundle (string)
The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.
--cli-read-timeout (int)
The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.
--cli-connect-timeout (int)
The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.
--cli-binary-format (string)
The formatting style to be used for binary blobs. The default format is base64. The base64 format expects binary blobs to be provided as a base64 encoded string. The raw-in-base64-out format preserves compatibility with AWS CLI V1 behavior and binary values must be passed literally. When providing contents from a file that map to a binary blob fileb:// will always be treated as binary and use the file contents directly regardless of the cli-binary-format setting. When using file:// the file contents will need to properly formatted for the configured cli-binary-format.
- base64
- raw-in-base64-out
--no-cli-pager (boolean)
Disable cli pager for output.
--cli-auto-prompt (boolean)
Automatically prompt for CLI input parameters.
--no-cli-auto-prompt (boolean)
Disable automatically prompt for CLI input parameters.
Examples
Note
To use the following examples, you must have the AWS CLI installed and configured. See the Getting started guide in the AWS CLI User Guide for more information.
Unless otherwise stated, all examples have unix-like quotation rules. These examples will need to be adapted to your terminal’s quoting rules. See Using quotation marks with strings in the AWS CLI User Guide .
Example 1: To start a new task
The following start-task example starts a task using the latest revision of the sleep360 task definition on the specified container instance in the default cluster.
aws ecs start-task \
--task-definition sleep360 \
--container-instances 765936fadbdd46b5991a4bd70c2a43d4
Output:
{
"tasks": [
{
"taskArn": "arn:aws:ecs:us-west-2:123456789012:task/default/666fdccc2e2d4b6894dd422f4eeee8f8",
"clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/default",
"taskDefinitionArn": "arn:aws:ecs:us-west-2:123456789012:task-definition/sleep360:3",
"containerInstanceArn": "arn:aws:ecs:us-west-2:123456789012:container-instance/default/765936fadbdd46b5991a4bd70c2a43d4",
"overrides": {
"containerOverrides": [
{
"name": "sleep"
}
]
},
"lastStatus": "PENDING",
"desiredStatus": "RUNNING",
"cpu": "128",
"memory": "128",
"containers": [
{
"containerArn": "arn:aws:ecs:us-west-2:123456789012:container/75f11ed4-8a3d-4f26-a33b-ad1db9e02d41",
"taskArn": "arn:aws:ecs:us-west-2:123456789012:task/default/666fdccc2e2d4b6894dd422f4eeee8f8",
"name": "sleep",
"lastStatus": "PENDING",
"networkInterfaces": [],
"cpu": "10",
"memory": "10"
}
],
"version": 1,
"createdAt": 1563421494.186,
"group": "family:sleep360",
"launchType": "EC2",
"attachments": [],
"tags": []
}
],
"failures": []
}
For more information, see Schedule your containers on Amazon ECS in the Amazon ECS Developer Guide.
Example 2: To configure an Amazon EBS volume at task start
The following start-task example configures an encrypted Amazon EBS volume for a task on the specified container instance. You must have an Amazon ECS infrastructure role configured with the AmazonECSInfrastructureRolePolicyForVolumes managed policy attached. You must specify a task definition with the same volume name as in the start-task request. This example uses the --cli-input-json option and a JSON input file called ebs.json with the following content.
aws ecs start-task \
--cli-input-json file://ebs.json \
--container-instances 765936fadbdd46b5991a4bd70c2a43d4
Contents of ebs.json:
{
"cluster": "default",
"taskDefinition": "mytaskdef",
"networkConfiguration":{
"awsvpcConfiguration":{
"assignPublicIp": "ENABLED",
"securityGroups": ["sg-12344321"],
"subnets":["subnet-12344321"]
}
},
"volumeConfigurations": [
{
"name": "myEBSVolume",
"managedEBSVolume": {
"volumeType": "gp3",
"sizeInGiB": 100,
"roleArn":"arn:aws:iam::123456789012:role/ecsInfrastructureRole",
"encrypted": true,
"kmsKeyId": "arn:aws:kms:region:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab"
}
}
]
}
Output:
{
"tasks": [
{
"attachments": [
{
"id": "aea29489-9dcd-49f1-8164-4d91566e1113",
"type": "ElasticNetworkInterface",
"status": "PRECREATED",
"details": [
{
"name": "subnetId",
"value": "subnet-12344321"
}
]
},
{
"id": "f29e1222-9a1e-410f-b499-a12a7cd6d42e",
"type": "AmazonElasticBlockStorage",
"status": "CREATED",
"details": [
{
"name": "roleArn",
"value": "arn:aws:iam::123456789012:role/ecsInfrastructureRole"
},
{
"name": "volumeName",
"value": "myEBSVolume"
},
{
"name": "deleteOnTermination",
"value": "true"
}
]
}
],
"attributes": [
{
"name": "ecs.cpu-architecture",
"value": "arm64"
}
],
"availabilityZone": "us-west-2c",
"clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/default",
"containerInstanceArn": "arn:aws:ecs:us-west-2:123456789012:container-instance/default/765936fadbdd46b5991a4bd70c2a43d4",
"containers": [
{
"containerArn": "arn:aws:ecs:us-west-2:123456789012:container/default/bb122ace3ed84add92c00a351a03c69e/a4a9ed10-51c7-4567-9653-50e71b94f867",
"taskArn": "arn:aws:ecs:us-west-2:123456789012:task/default/bb122ace3ed84add92c00a351a03c69e",
"name": "container-using-ebs",
"image": "amazonlinux:2",
"lastStatus": "PENDING",
"networkInterfaces": [],
"cpu": "0"
}
],
"cpu": "1024",
"createdAt": "2025-01-23T14:51:05.191000-06:00",
"desiredStatus": "RUNNING",
"enableExecuteCommand": false,
"group": "family:mytaskdef",
"lastStatus": "PROVISIONING",
"launchType": "EC2",
"memory": "3072",
"overrides": {
"containerOverrides": [
{
"name": "container-using-ebs"
}
],
"inferenceAcceleratorOverrides": []
},
"tags": [],
"taskArn": "arn:aws:ecs:us-west-2:123456789012:task/default/bb122ace3ed84add92c00a351a03c69e",
"taskDefinitionArn": "arn:aws:ecs:us-west-2:123456789012:task-definition/mytaskdef:4",
"version": 1
}
],
"failures": []
}
For more information, see Use Amazon EBS volumes with Amazon ECS in the Amazon ECS Developer Guide.
Output
tasks -> (list)
A full description of the tasks that were started. Each task that was successfully placed on your container instances is described.
(structure)
Details on a task in a cluster.
attachments -> (list)
The Elastic Network Adapter that’s associated with the task if the task uses the awsvpc network mode.
(structure)
An object representing a container instance or task attachment.
id -> (string)
type -> (string)
ElasticNetworkInterface , Service Connect , and AmazonElasticBlockStorage .status -> (string)
PRECREATED , CREATED , ATTACHING , ATTACHED , DETACHING , DETACHED , DELETED , and FAILED .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.
For Service Connect services, this includes portName , clientAliases , discoveryName , and ingressPortOverride .
For Elastic Block Storage, this includes roleArn , deleteOnTermination , volumeName , volumeId , and statusReason (only when the attachment fails to create or attach).
(structure)
A key-value pair object.
name -> (string)
value -> (string)
attributes -> (list)
The attributes of the task
(structure)
An attribute is a name-value pair that’s associated with an Amazon ECS object. Use attributes to extend the Amazon ECS data model by adding custom metadata to your resources. For more information, see Attributes in the Amazon Elastic Container Service Developer Guide .
name -> (string)
name must contain between 1 and 128 characters. The name may contain letters (uppercase and lowercase), numbers, hyphens (-), underscores (_), forward slashes (/), back slashes (), or periods (.).value -> (string)
value must contain between 1 and 128 characters. It can contain letters (uppercase and lowercase), numbers, hyphens (-), underscores (_), periods (.), at signs (@), forward slashes (/), back slashes (), colons (:), or spaces. The value can’t start or end with a space.targetType -> (string)
targetId -> (string)
availabilityZone -> (string)
capacityProviderName -> (string)
clusterArn -> (string)
connectivity -> (string)
connectivityAt -> (timestamp)
CONNECTED status.containerInstanceArn -> (string)
containers -> (list)
The containers that’s associated with the task.
(structure)
A Docker container that’s part of a task.
containerArn -> (string)
taskArn -> (string)
name -> (string)
image -> (string)
imageDigest -> (string)
runtimeId -> (string)
lastStatus -> (string)
exitCode -> (integer)
reason -> (string)
networkBindings -> (list)
The network bindings associated with the container.
(structure)
Details on the network bindings between a container and its host container instance. After a task reaches the RUNNING status, manual and automatic host and container port assignments are visible in the networkBindings section of DescribeTasks API responses.
bindIP -> (string)
containerPort -> (integer)
hostPort -> (integer)
protocol -> (string)
containerPortRange -> (string)
The port number range on the container that’s bound to the dynamically mapped host port range.
The following rules apply when you specify a containerPortRange :
- You must use either the
bridgenetwork mode or theawsvpcnetwork mode. - This parameter is available for both the EC2 and Fargate launch types.
- This parameter is available for both the Linux and Windows operating systems.
- The container instance must have at least version 1.67.0 of the container agent and at least version 1.67.0-1 of the
ecs-initpackage - You can specify a maximum of 100 port ranges per container.
- You do not specify a
hostPortRange. The value of thehostPortRangeis set as follows:- For containers in a task with the
awsvpcnetwork mode, thehostPortRangeis set to the same value as thecontainerPortRange. This is a static mapping strategy. - For containers in a task with the
bridgenetwork mode, the Amazon ECS agent finds open host ports from the default ephemeral range and passes it to docker to bind them to the container ports.
- For containers in a task with the
- The
containerPortRangevalid values are between 1 and 65535. - A port can only be included in one port mapping per container.
- You cannot specify overlapping port ranges.
- The first port in the range must be less than last port in the range.
- Docker recommends that you turn off the docker-proxy in the Docker daemon config file when you have a large number of ports. For more information, see Issue #11185 on the Github website. For information about how to turn off the docker-proxy in the Docker daemon config file, see Docker daemon in the Amazon ECS Developer Guide .
You can call ` DescribeTasks https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTasks.html`__ to view the hostPortRange which are the host ports that are bound to the container ports.
hostPortRange -> (string)
networkInterfaces -> (list)
The network interfaces associated with the container.
(structure)
An object representing the elastic network interface for tasks that use the awsvpc network mode.
attachmentId -> (string)
privateIpv4Address -> (string)
ipv6Address -> (string)
healthStatus -> (string)
UNKNOWN .managedAgents -> (list)
The details of any Amazon ECS managed agents associated with the container.
(structure)
Details about the managed agent status for the container.
lastStartedAt -> (timestamp)
name -> (string)
ExecuteCommandAgent .reason -> (string)
lastStatus -> (string)
cpu -> (string)
0 if no value was specified in the container definition when the task definition was registered.memory -> (string)
memoryReservation -> (string)
gpuIds -> (list)
The IDs of each GPU assigned to the container.
(string)
cpu -> (string)
The number of CPU units used by the task as expressed in a task definition. It can be expressed as an integer using CPU units (for example, 1024 ). It can also be expressed as a string using vCPUs (for example, 1 vCPU or 1 vcpu ). String values are converted to an integer that indicates the CPU units when the task definition is registered.
If you’re using the EC2 launch type or the external launch type, this field is optional. Supported values are between 128 CPU units (0.125 vCPUs) and 196608 CPU units (192 vCPUs). If you do not specify a value, the parameter is ignored.
This field is required for Fargate. For information about the valid values, see Task size in the Amazon Elastic Container Service Developer Guide .
createdAt -> (timestamp)
PENDING state.desiredStatus -> (string)
enableExecuteCommand -> (boolean)
true , execute command functionality is turned on all the containers in the task.executionStoppedAt -> (timestamp)
group -> (string)
healthStatus -> (string)
The health status for the task. It’s determined by the health of the essential containers in the task. If all essential containers in the task are reporting as HEALTHY , the task status also reports as HEALTHY . If any essential containers in the task are reporting as UNHEALTHY or UNKNOWN , the task status also reports as UNHEALTHY or UNKNOWN .
Note
The Amazon ECS container agent doesn’t monitor or report on Docker health checks that are embedded in a container image and not specified in the container definition. For example, this includes those specified in a parent image or from the image’s Dockerfile. Health check parameters that are specified in a container definition override any Docker health checks that are found in the container image.inferenceAccelerators -> (list)
The Elastic Inference accelerator that’s associated with the task.
(structure)
Details on an Elastic Inference accelerator. For more information, see Working with Amazon Elastic Inference on Amazon ECS in the Amazon Elastic Container Service Developer Guide .
deviceName -> (string)
deviceName must also be referenced in a container definition as a ResourceRequirement .deviceType -> (string)
lastStatus -> (string)
launchType -> (string)
memory -> (string)
The amount of memory (in MiB) that the task uses as expressed in a task definition. It can be expressed as an integer using MiB (for example, 1024 ). If it’s expressed as a string using GB (for example, 1GB or 1 GB ), it’s converted to an integer indicating the MiB when the task definition is registered.
If you use the EC2 launch type, this field is optional.
If you use the Fargate launch type, this field is required. You must use one of the following values. The value that you choose determines the range of supported values for the cpu parameter.
- 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available
cpuvalues: 256 (.25 vCPU) - 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available
cpuvalues: 512 (.5 vCPU) - 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available
cpuvalues: 1024 (1 vCPU) - Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available
cpuvalues: 2048 (2 vCPU) - Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available
cpuvalues: 4096 (4 vCPU) - Between 16 GB and 60 GB in 4 GB increments - Available
cpuvalues: 8192 (8 vCPU) This option requires Linux platform1.4.0or later. - Between 32GB and 120 GB in 8 GB increments - Available
cpuvalues: 16384 (16 vCPU) This option requires Linux platform1.4.0or later.
overrides -> (structure)
One or more container overrides.
containerOverrides -> (list)
One or more container overrides that are sent to a task.
(structure)
The overrides that are sent to a container. An empty container override can be passed in. An example of an empty container override is {"containerOverrides": [ ] } . If a non-empty container override is specified, the name parameter must be included.
You can use Secrets Manager or Amazon Web Services Systems Manager Parameter Store to store the sensitive data. For more information, see Retrieve secrets through environment variables in the Amazon ECS Developer Guide.
name -> (string)
command -> (list)
The command to send to the container that overrides the default command from the Docker image or the task definition. You must also specify a container name.
(string)
environment -> (list)
The environment variables to send to the container. You can add new environment variables, which are added to the container at launch, or you can override the existing environment variables from the Docker image or the task definition. You must also specify a container name.
(structure)
A key-value pair object.
name -> (string)
value -> (string)
environmentFiles -> (list)
A list of files containing the environment variables to pass to a container, instead of the value from the container definition.
(structure)
A list of files containing the environment variables to pass to a container. You can specify up to ten environment files. The file must have a .env file extension. Each line in an environment file should contain an environment variable in VARIABLE=VALUE format. Lines beginning with # are treated as comments and are ignored.
If there are environment variables specified using the environment parameter in a container definition, they take precedence over the variables contained within an environment file. If multiple environment files are specified that contain the same variable, they’re processed from the top down. We recommend that you use unique variable names. For more information, see Use a file to pass environment variables to a container in the Amazon Elastic Container Service Developer Guide .
Environment variable files are objects in Amazon S3 and all Amazon S3 security considerations apply.
You must use the following platforms for the Fargate launch type:
- Linux platform version
1.4.0or later. - Windows platform version
1.0.0or later.
Consider the following when using the Fargate launch type:
- The file is handled like a native Docker env-file.
- There is no support for shell escape handling.
- The container entry point interperts the
VARIABLEvalues.
value -> (string)
type -> (string)
s3 .cpu -> (integer)
cpu units reserved for the container, instead of the default value from the task definition. You must also specify a container name.memory -> (integer)
memoryReservation -> (integer)
resourceRequirements -> (list)
The type and amount of a resource to assign to a container, instead of the default value from the task definition. The only supported resource is a GPU.
(structure)
The type and amount of a resource to assign to a container. The supported resource types are GPUs and Elastic Inference accelerators. For more information, see Working with GPUs on Amazon ECS or Working with Amazon Elastic Inference on Amazon ECS in the Amazon Elastic Container Service Developer Guide
value -> (string)
The value for the specified resource type.
When the type is GPU , the value is the number of physical GPUs the Amazon ECS container agent reserves for the container. The number of GPUs that’s reserved for all containers in a task can’t exceed the number of available GPUs on the container instance that the task is launched on.
When the type is InferenceAccelerator , the value matches the deviceName for an InferenceAccelerator specified in a task definition.
type -> (string)
cpu -> (string)
inferenceAcceleratorOverrides -> (list)
The Elastic Inference accelerator override for the task.
(structure)
Details on an Elastic Inference accelerator task override. This parameter is used to override the Elastic Inference accelerator specified in the task definition. For more information, see Working with Amazon Elastic Inference on Amazon ECS in the Amazon Elastic Container Service Developer Guide .
deviceName -> (string)
deviceName specified in the task definition.deviceType -> (string)
executionRoleArn -> (string)
memory -> (string)
taskRoleArn -> (string)
ephemeralStorage -> (structure)
The ephemeral storage setting override for the task.
Note
This parameter is only supported for tasks hosted on Fargate that use the following platform versions:
- Linux platform version
1.4.0or later. - Windows platform version
1.0.0or later.
sizeInGiB -> (integer)
21 GiB and the maximum supported value is 200 GiB.platformVersion -> (string)
LATEST platform version is used. For more information, see Fargate Platform Versions in the Amazon Elastic Container Service Developer Guide .platformFamily -> (string)
The operating system that your tasks are running on. A platform family is specified only for tasks that use the Fargate launch type.
All tasks that run as part of this service must use the same platformFamily value as the service (for example, LINUX. ).
pullStartedAt -> (timestamp)
pullStoppedAt -> (timestamp)
startedAt -> (timestamp)
PENDING state to the RUNNING state.startedBy -> (string)
startedBy parameter contains the deployment ID of that service.stopCode -> (string)
The stop code indicating why a task was stopped. The stoppedReason might contain additional details.
For more information about stop code, see Stopped tasks error codes in the Amazon ECS Developer Guide .
stoppedAt -> (timestamp)
RUNNING state to the STOPPED state.stoppedReason -> (string)
stoppingAt -> (timestamp)
RUNNING state to STOPPING .tags -> (list)
The metadata that you apply to the task to help you categorize and organize the task. Each tag consists of a key and an optional value. You define both the key and value.
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 Amazon Web Services 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. You define them.
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 Amazon Web Services 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)
key is a general label that acts like a category for more specific tag values.value -> (string)
value acts as a descriptor within a tag category (key).taskArn -> (string)
taskDefinitionArn -> (string)
version -> (long)
detail object) to verify that the version in your event stream is current.ephemeralStorage -> (structure)
The ephemeral storage settings for the task.
sizeInGiB -> (integer)
21 GiB and the maximum supported value is 200 GiB.fargateEphemeralStorage -> (structure)
The Fargate ephemeral storage settings for the task.
sizeInGiB -> (integer)
20 GiB and the maximum supported value is 200 GiB.kmsKeyId -> (string)
failures -> (list)
Any failures associated with the call.
(structure)
A failed resource. For a list of common causes, see API failure reasons in the Amazon Elastic Container Service Developer Guide .
arn -> (string)
reason -> (string)
detail -> (string)
© Copyright 2025, Amazon Web Services. Created using Sphinx.