DescribeTasks - Amazon Elastic Container Service

DescribeTasks

Describes a specified task or tasks.

Currently, stopped tasks appear in the returned results for at least one hour.

If you have tasks with tags, and then delete the cluster, the tagged tasks are returned in the response. If you create a new cluster with the same name as the deleted cluster, the tagged tasks are not included in the response.

Request Syntax

{ "cluster": "string", "include": [ "string" ], "tasks": [ "string" ] }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

cluster

The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task or tasks to describe. If you do not specify a cluster, the default cluster is assumed. This parameter is required. If you do not specify a value, the default cluster is used.

Type: String

Required: No

include

Specifies whether you want to see the resource tags for the task. If TAGS is specified, the tags are included in the response. If this field is omitted, tags aren't included in the response.

Type: Array of strings

Valid Values: TAGS

Required: No

tasks

A list of up to 100 task IDs or full ARN entries.

Type: Array of strings

Required: Yes

Response Syntax

{ "failures": [ { "arn": "string", "detail": "string", "reason": "string" } ], "tasks": [ { "attachments": [ { "details": [ { "name": "string", "value": "string" } ], "id": "string", "status": "string", "type": "string" } ], "attributes": [ { "name": "string", "targetId": "string", "targetType": "string", "value": "string" } ], "availabilityZone": "string", "capacityProviderName": "string", "clusterArn": "string", "connectivity": "string", "connectivityAt": number, "containerInstanceArn": "string", "containers": [ { "containerArn": "string", "cpu": "string", "exitCode": number, "gpuIds": [ "string" ], "healthStatus": "string", "image": "string", "imageDigest": "string", "lastStatus": "string", "managedAgents": [ { "lastStartedAt": number, "lastStatus": "string", "name": "string", "reason": "string" } ], "memory": "string", "memoryReservation": "string", "name": "string", "networkBindings": [ { "bindIP": "string", "containerPort": number, "containerPortRange": "string", "hostPort": number, "hostPortRange": "string", "protocol": "string" } ], "networkInterfaces": [ { "attachmentId": "string", "ipv6Address": "string", "privateIpv4Address": "string" } ], "reason": "string", "runtimeId": "string", "taskArn": "string" } ], "cpu": "string", "createdAt": number, "desiredStatus": "string", "enableExecuteCommand": boolean, "ephemeralStorage": { "sizeInGiB": number }, "executionStoppedAt": number, "fargateEphemeralStorage": { "kmsKeyId": "string", "sizeInGiB": number }, "group": "string", "healthStatus": "string", "inferenceAccelerators": [ { "deviceName": "string", "deviceType": "string" } ], "lastStatus": "string", "launchType": "string", "memory": "string", "overrides": { "containerOverrides": [ { "command": [ "string" ], "cpu": number, "environment": [ { "name": "string", "value": "string" } ], "environmentFiles": [ { "type": "string", "value": "string" } ], "memory": number, "memoryReservation": number, "name": "string", "resourceRequirements": [ { "type": "string", "value": "string" } ] } ], "cpu": "string", "ephemeralStorage": { "sizeInGiB": number }, "executionRoleArn": "string", "inferenceAcceleratorOverrides": [ { "deviceName": "string", "deviceType": "string" } ], "memory": "string", "taskRoleArn": "string" }, "platformFamily": "string", "platformVersion": "string", "pullStartedAt": number, "pullStoppedAt": number, "startedAt": number, "startedBy": "string", "stopCode": "string", "stoppedAt": number, "stoppedReason": "string", "stoppingAt": number, "tags": [ { "key": "string", "value": "string" } ], "taskArn": "string", "taskDefinitionArn": "string", "version": number } ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

failures

Any failures associated with the call.

Type: Array of Failure objects

tasks

The list of tasks.

Type: Array of Task objects

Errors

For information about the errors that are common to all actions, see Common Errors.

ClientException

These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.

The following list includes additional causes for the error:

  • The RunTask could not be processed because you use managed scaling and there is a capacity error because the quota of tasks in the PROVISIONING per cluster has been reached. For information about the service quotas, see Amazon ECS service quotas.

HTTP Status Code: 400

ClusterNotFoundException

The specified cluster wasn't found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region specific.

HTTP Status Code: 400

InvalidParameterException

The specified parameter isn't valid. Review the available parameters for the API request.

HTTP Status Code: 400

ServerException

These errors are usually caused by a server issue.

HTTP Status Code: 500

Examples

In the following example or examples, the Authorization header contents (AUTHPARAMS) must be replaced with an AWS Signature Version 4 signature. For more information, see Signature Version 4 Signing Process in the AWS General Reference.

You only need to learn how to sign HTTP requests if you intend to create them manually. When you use the AWS Command Line Interface or one of the AWS SDKs to make requests to AWS, these tools automatically sign the requests for you, with the access key that you specify when you configure the tools. When you use these tools, you don't have to sign requests yourself.

Example

This example request provides descriptive information about a task with an ID of 1dc5c17a-422b-4dc4-b493-371970c6c4d6 in the default cluster.

Sample Request

POST / HTTP/1.1 Host: ecs.us-east-1.amazonaws.com Accept-Encoding: identity Content-Length: 51 X-Amz-Target: AmazonEC2ContainerServiceV20141113.DescribeTasks X-Amz-Date: 20161121T214915Z User-Agent: aws-cli/1.11.13 Python/2.7.12 Darwin/16.1.0 botocore/1.4.66 Content-Type: application/x-amz-json-1.1 Authorization: AUTHPARAMS { "tasks": [ "1dc5c17a-422b-4dc4-b493-371970c6c4d6" ] }

Sample Response

HTTP/1.1 200 OK Server: Server Date: Mon, 21 Nov 2016 21:49:16 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 1238 Connection: keep-alive x-amzn-RequestId: 123a4b56-7c89-01d2-3ef4-example5678f { "failures": [], "tasks": [ { "taskArn": "arn:aws:ecs:us-east-1:012345678910:task/1dc5c17a-422b-4dc4-b493-371970c6c4d6", "overrides": { "containerOverrides": [ { "name": "simple-app" }, { "name": "busybox" } ] }, "lastStatus": "RUNNING", "containerInstanceArn": "arn:aws:ecs:us-east-1:012345678910:container-instance/default/5991d8da-1d59-49d2-a31f-4230f9e73140", "createdAt": 1476822811.295, "version": 0, "clusterArn": "arn:aws:ecs:us-east-1:012345678910:cluster/default", "startedAt": 1476822833.998, "desiredStatus": "RUNNING", "taskDefinitionArn": "arn:aws:ecs:us-east-1:012345678910:task-definition/console-sample-app-dynamic-ports:1", "startedBy": "ecs-svc/9223370560032507596", "containers": [ { "containerArn": "arn:aws:ecs:us-east-1:012345678910:container/4df26bb4-f057-467b-a079-961675296e64", "taskArn": "arn:aws:ecs:us-east-1:012345678910:task/default/1dc5c17a-422b-4dc4-b493-371970c6c4d6", "lastStatus": "RUNNING", "name": "simple-app", "networkBindings": [ { "protocol": "tcp", "bindIP": "0.0.0.0", "containerPort": 80, "hostPort": 32774 } ] }, { "containerArn": "arn:aws:ecs:us-east-1:012345678910:container/e09064f7-7361-4c87-8ab9-8d073bbdbcb9", "taskArn": "arn:aws:ecs:us-east-1:012345678910:task/default/1dc5c17a-422b-4dc4-b493-371970c6c4d6", "lastStatus": "RUNNING", "name": "busybox", "networkBindings": [] } ] } ] }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: