Menu
Amazon EC2 Container Service
API Reference (API Version 2014-11-13)

DescribeTasks

Describes a specified task or tasks.

Request Syntax

Copy
{ "cluster": "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 to describe. If you do not specify a cluster, the default cluster is assumed.

Type: String

Required: No

tasks

A list of up to 100 task IDs or full Amazon Resource Name (ARN) entries.

Type: array of Strings

Required: Yes

Response Syntax

Copy
{ "failures": [ { "arn": "string", "reason": "string" } ], "tasks": [ { "clusterArn": "string", "containerInstanceArn": "string", "containers": [ { "containerArn": "string", "exitCode": number, "lastStatus": "string", "name": "string", "networkBindings": [ { "bindIP": "string", "containerPort": number, "hostPort": number, "protocol": "string" } ], "reason": "string", "taskArn": "string" } ], "createdAt": number, "desiredStatus": "string", "group": "string", "lastStatus": "string", "overrides": { "containerOverrides": [ { "command": [ "string" ], "environment": [ { "name": "string", "value": "string" } ], "name": "string" } ], "taskRoleArn": "string" }, "startedAt": number, "startedBy": "string", "stoppedAt": number, "stoppedReason": "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, such as using an action or resource on behalf of a user that doesn't have permission to use the action or resource, or specifying an identifier that is not valid.

HTTP Status Code: 400

ClusterNotFoundException

The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are region-specific.

HTTP Status Code: 400

InvalidParameterException

The specified parameter is invalid. 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

Example

In the following example or examples, the Authorization header contents (AUTHPARAMS) must be replaced with an AWS Signature Version 4 signature. For more information about creating these signatures, 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 manually create them. When you use the AWS Command Line Interface (AWS CLI) 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 need to learn how 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

Copy
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

Copy
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/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/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/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: