Skip to content

aws.ecs.describe_tasks

Example SQL Queries

SELECT * FROM
aws.ecs.describe_tasks
WHERE
"tasks" = 'VALUE';

Description

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.

Table Definition

Column NameColumn Data Type
cluster Input Column

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 the task or tasks you are describing were launched in any cluster other than the default cluster.

VARCHAR
include Input Column

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.

VARCHAR[]
Show child fields
include[]
_aws_profile Input Column

The AWS profile defines the AWS identity used. It can be defined via credentials or by assuming a IAM role.

STRUCT(
"type" VARCHAR,
"name" VARCHAR,
"account_id" VARCHAR,
"via_profile_name" VARCHAR,
"assumed_role_arn" VARCHAR,
"organization" STRUCT(
"account_name" VARCHAR,
"id" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[],
"master_account" STRUCT(
"id" VARCHAR,
"email" VARCHAR
),
"parents" STRUCT(
"type" VARCHAR,
"id" VARCHAR,
"name" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[]
)[]
)
)
Show child fields
_aws_profile.account_id

The AWS account id

_aws_profile.assumed_role_arn

The ARN of the assumed role

_aws_profile.name

The unique name of the profile.

_aws_profile.organization

Information about this profile's membership in the AWS organization.

Show child fields
_aws_profile.organization.account_name

The name of account speciifed by the organization

_aws_profile.organization.id

The organization id

_aws_profile.organization.master_account
Show child fields
_aws_profile.organization.master_account.email

The organization master account email address

_aws_profile.organization.master_account.id

The organization master account id

_aws_profile.organization.parents[]
Show child fields
_aws_profile.organization.parents[].id

The id of the parent

_aws_profile.organization.parents[].name

The name of the parent

_aws_profile.organization.parents[].tags[]
Show child fields
_aws_profile.organization.parents[].tags[].key
_aws_profile.organization.parents[].tags[].value
_aws_profile.organization.parents[].type

The type of parent can be an organization unit or a root

_aws_profile.organization.tags[]
Show child fields
_aws_profile.organization.tags[].key
_aws_profile.organization.tags[].value
_aws_profile.type

The type of profile, either 'credentials' or 'assumed_role'

_aws_profile.via_profile_name

This IAM role for this profile is assumed by first utilizing another profile with this name to obtain credentials.

_aws_region Input Column

The AWS region to use.

VARCHAR
_input_tasks Input Column
VARCHAR[]
Show child fields
_input_tasks[]
tasks

The list of tasks.

STRUCT(
"attachments" STRUCT(
"id" VARCHAR,
"type" VARCHAR,
"status" VARCHAR,
"details" STRUCT(
"name" VARCHAR,
"value" VARCHAR
)[]
)[],
"attributes" STRUCT(
"name" VARCHAR,
"value" VARCHAR,
"target_type" VARCHAR,
"target_id" VARCHAR
)[],
"availability_zone" VARCHAR,
"capacity_provider_name" VARCHAR,
"cluster_arn" VARCHAR,
"connectivity" VARCHAR,
"connectivity_at" TIMESTAMP_S,
"container_instance_arn" VARCHAR,
"containers" STRUCT(
"container_arn" VARCHAR,
"task_arn" VARCHAR,
"name" VARCHAR,
"image" VARCHAR,
"image_digest" VARCHAR,
"runtime_id" VARCHAR,
"last_status" VARCHAR,
"exit_code" BIGINT,
"reason" VARCHAR,
"network_bindings" STRUCT(
"bind_ip" VARCHAR,
"container_port" BIGINT,
"host_port" BIGINT,
"protocol" VARCHAR,
"container_port_range" VARCHAR,
"host_port_range" VARCHAR
)[],
"network_interfaces" STRUCT(
"attachment_id" VARCHAR,
"private_ipv4_address" VARCHAR,
"ipv6_address" VARCHAR
)[],
"health_status" VARCHAR,
"managed_agents" STRUCT(
"last_started_at" TIMESTAMP_S,
"name" VARCHAR,
"reason" VARCHAR,
"last_status" VARCHAR
)[],
"cpu" VARCHAR,
"memory" VARCHAR,
"memory_reservation" VARCHAR,
"gpu_ids" VARCHAR[]
)[],
"cpu" VARCHAR,
"created_at" TIMESTAMP_S,
"desired_status" VARCHAR,
"enable_execute_command" BOOLEAN,
"execution_stopped_at" TIMESTAMP_S,
"group" VARCHAR,
"health_status" VARCHAR,
"inference_accelerators" STRUCT(
"device_name" VARCHAR,
"device_type" VARCHAR
)[],
"last_status" VARCHAR,
"launch_type" VARCHAR,
"memory" VARCHAR,
"overrides" STRUCT(
"container_overrides" STRUCT(
"name" VARCHAR,
"command" VARCHAR[],
"environment" STRUCT(
"name" VARCHAR,
"value" VARCHAR
)[],
"environment_files" STRUCT(
"value" VARCHAR,
"type" VARCHAR
)[],
"cpu" BIGINT,
"memory" BIGINT,
"memory_reservation" BIGINT,
"resource_requirements" STRUCT(
"value" VARCHAR,
"type" VARCHAR
)[]
)[],
"cpu" VARCHAR,
"inference_accelerator_overrides" STRUCT(
"device_name" VARCHAR,
"device_type" VARCHAR
)[],
"execution_role_arn" VARCHAR,
"memory" VARCHAR,
"task_role_arn" VARCHAR,
"ephemeral_storage" STRUCT(
"size_in_gi_b" BIGINT
)
),
"platform_version" VARCHAR,
"platform_family" VARCHAR,
"pull_started_at" TIMESTAMP_S,
"pull_stopped_at" TIMESTAMP_S,
"started_at" TIMESTAMP_S,
"started_by" VARCHAR,
"stop_code" VARCHAR,
"stopped_at" TIMESTAMP_S,
"stopped_reason" VARCHAR,
"stopping_at" TIMESTAMP_S,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[],
"task_arn" VARCHAR,
"task_definition_arn" VARCHAR,
"version" BIGINT,
"ephemeral_storage" STRUCT(
"size_in_gi_b" BIGINT
),
"fargate_ephemeral_storage" STRUCT(
"size_in_gi_b" BIGINT,
"kms_key_id" VARCHAR
)
)[]
Show child fields
tasks[]
Show child fields
tasks[].attachments[]
Show child fields
tasks[].attachments[].details[]
Show child fields
tasks[].attachments[].details[].name

The name of the key-value pair. For environment variables, this is the name of the environment variable.

tasks[].attachments[].details[].value

The value of the key-value pair. For environment variables, this is the value of the environment variable.

tasks[].attachments[].id

The unique identifier for the attachment.

tasks[].attachments[].status

The status of the attachment. Valid values are PRECREATED, CREATED, ATTACHING, ATTACHED, DETACHING, DETACHED, DELETED, and FAILED.

tasks[].attachments[].type

The type of the attachment, such as ElasticNetworkInterface, Service Connect, and AmazonElasticBlockStorage.

tasks[].attributes[]
Show child fields
tasks[].attributes[].name

The name of the attribute. The 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 (.).

tasks[].attributes[].target_id

The ID of the target. You can specify the short form ID for a resource or the full Amazon Resource Name (ARN).

tasks[].attributes[].target_type

The type of the target to attach the attribute with. This parameter is required if you use the short form ID for a resource instead of the full ARN.

tasks[].attributes[].value

The value of the attribute. The 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.

tasks[].availability_zone

The Availability Zone for the task.

tasks[].capacity_provider_name

The capacity provider that's associated with the task.

tasks[].cluster_arn

The ARN of the cluster that hosts the task.

tasks[].connectivity

The connectivity status of a task.

tasks[].connectivity_at

The Unix timestamp for the time when the task last went into CONNECTED status.

tasks[].container_instance_arn

The ARN of the container instances that host the task.

tasks[].containers[]
Show child fields
tasks[].containers[].container_arn

The Amazon Resource Name (ARN) of the container.

tasks[].containers[].cpu

The number of CPU units set for the container. The value is 0 if no value was specified in the container definition when the task definition was registered.

tasks[].containers[].exit_code

The exit code returned from the container.

tasks[].containers[].gpu_ids[]
tasks[].containers[].health_status

The health status of the container. If health checks aren't configured for this container in its task definition, then it reports the health status as UNKNOWN.

tasks[].containers[].image

The image used for the container.

tasks[].containers[].image_digest

The container image manifest digest.

tasks[].containers[].last_status

The last known status of the container.

tasks[].containers[].managed_agents[]
Show child fields
tasks[].containers[].managed_agents[].last_started_at

The Unix timestamp for the time when the managed agent was last started.

tasks[].containers[].managed_agents[].last_status

The last known status of the managed agent.

tasks[].containers[].managed_agents[].name

The name of the managed agent. When the execute command feature is turned on, the managed agent name is ExecuteCommandAgent.

tasks[].containers[].managed_agents[].reason

The reason for why the managed agent is in the state it is in.

tasks[].containers[].memory

The hard limit (in MiB) of memory set for the container.

tasks[].containers[].memory_reservation

The soft limit (in MiB) of memory set for the container.

tasks[].containers[].name

The name of the container.

tasks[].containers[].network_bindings[]
Show child fields
tasks[].containers[].network_bindings[].bind_ip

The IP address that the container is bound to on the container instance.

tasks[].containers[].network_bindings[].container_port

The port number on the container that's used with the network binding.

tasks[].containers[].network_bindings[].container_port_range

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 bridge network mode or the awsvpc network 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-init package

  • You can specify a maximum of 100 port ranges per container.

  • You do not specify a hostPortRange. The value of the hostPortRange is set as follows:

    • For containers in a task with the awsvpc network mode, the hostPortRange is set to the same value as the containerPortRange. This is a static mapping strategy.

    • For containers in a task with the bridge network 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.

  • The containerPortRange valid 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 to view the hostPortRange which are the host ports that are bound to the container ports.

tasks[].containers[].network_bindings[].host_port

The port number on the host that's used with the network binding.

tasks[].containers[].network_bindings[].host_port_range

The port number range on the host that's used with the network binding. This is assigned is assigned by Docker and delivered by the Amazon ECS agent.

tasks[].containers[].network_bindings[].protocol

The protocol used for the network binding.

tasks[].containers[].network_interfaces[]
Show child fields
tasks[].containers[].network_interfaces[].attachment_id

The attachment ID for the network interface.

tasks[].containers[].network_interfaces[].ipv6_address

The private IPv6 address for the network interface.

tasks[].containers[].network_interfaces[].private_ipv4_address

The private IPv4 address for the network interface.

tasks[].containers[].reason

A short (255 max characters) human-readable string to provide additional details about a running or stopped container.

tasks[].containers[].runtime_id

The ID of the Docker container.

tasks[].containers[].task_arn

The ARN of the task.

tasks[].cpu

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 use the EC2 launch type, this field is optional. Supported values are between 128 CPU units (0.125 vCPUs) and 10240 CPU units (10 vCPUs).

If you use the Fargate launch type, this field is required. You must use one of the following values. These values determine the range of supported values for the memory parameter:

The CPU units cannot be less than 1 vCPU when you use Windows containers on Fargate.

  • 256 (.25 vCPU) - Available memory values: 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB)

  • 512 (.5 vCPU) - Available memory values: 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB)

  • 1024 (1 vCPU) - Available memory values: 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB)

  • 2048 (2 vCPU) - Available memory values: 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB)

  • 4096 (4 vCPU) - Available memory values: 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB)

  • 8192 (8 vCPU) - Available memory values: 16 GB and 60 GB in 4 GB increments

    This option requires Linux platform 1.4.0 or later.

  • 16384 (16vCPU) - Available memory values: 32GB and 120 GB in 8 GB increments

    This option requires Linux platform 1.4.0 or later.

tasks[].created_at

The Unix timestamp for the time when the task was created. More specifically, it's for the time when the task entered the PENDING state.

tasks[].desired_status

The desired status of the task. For more information, see Task Lifecycle.

tasks[].enable_execute_command

Determines whether execute command functionality is turned on for this task. If true, execute command functionality is turned on all the containers in the task.

tasks[].ephemeral_storage

The ephemeral storage settings for the task.

Show child fields
tasks[].ephemeral_storage.size_in_gi_b

The total amount, in GiB, of ephemeral storage to set for the task. The minimum supported value is 20 GiB and the maximum supported value is 200 GiB.

tasks[].execution_stopped_at

The Unix timestamp for the time when the task execution stopped.

tasks[].fargate_ephemeral_storage

The Fargate ephemeral storage settings for the task.

Show child fields
tasks[].fargate_ephemeral_storage.kms_key_id

Specify an Key Management Service key ID to encrypt the ephemeral storage for the task.

tasks[].fargate_ephemeral_storage.size_in_gi_b

The total amount, in GiB, of the ephemeral storage to set for the task. The minimum supported value is 20 GiB and the maximum supported value is
 200 GiB.

tasks[].group

The name of the task group that's associated with the task.

tasks[].health_status

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.

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.

tasks[].inference_accelerators[]
Show child fields
tasks[].inference_accelerators[].device_name

The Elastic Inference accelerator device name. The deviceName must also be referenced in a container definition as a ResourceRequirement.

tasks[].inference_accelerators[].device_type

The Elastic Inference accelerator type to use.

tasks[].last_status

The last known status for the task. For more information, see Task Lifecycle.

tasks[].launch_type

The infrastructure where your task runs on. For more information, see Amazon ECS launch types in the Amazon Elastic Container Service Developer Guide.

tasks[].memory

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 cpu values: 256 (.25 vCPU)

  • 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu values: 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 cpu values: 1024 (1 vCPU)

  • Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available cpu values: 2048 (2 vCPU)

  • Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU)

  • Between 16 GB and 60 GB in 4 GB increments - Available cpu values: 8192 (8 vCPU)

    This option requires Linux platform 1.4.0 or later.

  • Between 32GB and 120 GB in 8 GB increments - Available cpu values: 16384 (16 vCPU)

    This option requires Linux platform 1.4.0 or later.

tasks[].overrides

One or more container overrides.

Show child fields
tasks[].overrides.container_overrides[]
Show child fields
tasks[].overrides.container_overrides[].command[]
tasks[].overrides.container_overrides[].cpu

The number of cpu units reserved for the container, instead of the default value from the task definition. You must also specify a container name.

tasks[].overrides.container_overrides[].environment[]
Show child fields
tasks[].overrides.container_overrides[].environment[].name

The name of the key-value pair. For environment variables, this is the name of the environment variable.

tasks[].overrides.container_overrides[].environment[].value

The value of the key-value pair. For environment variables, this is the value of the environment variable.

tasks[].overrides.container_overrides[].environment_files[]
Show child fields
tasks[].overrides.container_overrides[].environment_files[].type

The file type to use. Environment files are objects in Amazon S3. The only supported value is s3.

tasks[].overrides.container_overrides[].environment_files[].value

The Amazon Resource Name (ARN) of the Amazon S3 object containing the environment variable file.

tasks[].overrides.container_overrides[].memory

The hard limit (in MiB) of memory to present to the container, instead of the default value from the task definition. If your container attempts to exceed the memory specified here, the container is killed. You must also specify a container name.

tasks[].overrides.container_overrides[].memory_reservation

The soft limit (in MiB) of memory to reserve for the container, instead of the default value from the task definition. You must also specify a container name.

tasks[].overrides.container_overrides[].name

The name of the container that receives the override. This parameter is required if any override is specified.

tasks[].overrides.container_overrides[].resource_requirements[]
Show child fields
tasks[].overrides.container_overrides[].resource_requirements[].type

The type of resource to assign to a container.

tasks[].overrides.container_overrides[].resource_requirements[].value

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.

tasks[].overrides.cpu

The CPU override for the task.

tasks[].overrides.ephemeral_storage

The ephemeral storage setting override for the task.

This parameter is only supported for tasks hosted on Fargate that use the following platform versions:

  • Linux platform version 1.4.0 or later.

  • Windows platform version 1.0.0 or later.

Show child fields
tasks[].overrides.ephemeral_storage.size_in_gi_b

The total amount, in GiB, of ephemeral storage to set for the task. The minimum supported value is 20 GiB and the maximum supported value is 200 GiB.

tasks[].overrides.execution_role_arn

The Amazon Resource Name (ARN) of the task execution role override for the task. For more information, see Amazon ECS task execution IAM role in the Amazon Elastic Container Service Developer Guide.

tasks[].overrides.inference_accelerator_overrides[]
Show child fields
tasks[].overrides.inference_accelerator_overrides[].device_name

The Elastic Inference accelerator device name to override for the task. This parameter must match a deviceName specified in the task definition.

tasks[].overrides.inference_accelerator_overrides[].device_type

The Elastic Inference accelerator type to use.

tasks[].overrides.memory

The memory override for the task.

tasks[].overrides.task_role_arn

The Amazon Resource Name (ARN) of the role that containers in this task can assume. All containers in this task are granted the permissions that are specified in this role. For more information, see IAM Role for Tasks in the Amazon Elastic Container Service Developer Guide.

tasks[].platform_family

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.).

tasks[].platform_version

The platform version where your task runs on. A platform version is only specified for tasks that use the Fargate launch type. If you didn't specify one, the LATEST platform version is used. For more information, see Fargate Platform Versions in the Amazon Elastic Container Service Developer Guide.

tasks[].pull_started_at

The Unix timestamp for the time when the container image pull began.

tasks[].pull_stopped_at

The Unix timestamp for the time when the container image pull completed.

tasks[].started_at

The Unix timestamp for the time when the task started. More specifically, it's for the time when the task transitioned from the PENDING state to the RUNNING state.

tasks[].started_by

The tag specified when a task is started. If an Amazon ECS service started the task, the startedBy parameter contains the deployment ID of that service.

tasks[].stop_code

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.

tasks[].stopped_at

The Unix timestamp for the time when the task was stopped. More specifically, it's for the time when the task transitioned from the RUNNING state to the STOPPED state.

tasks[].stopped_reason

The reason that the task was stopped.

tasks[].stopping_at

The Unix timestamp for the time when the task stops. More specifically, it's for the time when the task transitions from the RUNNING state to STOPPING.

tasks[].tags[]
Show child fields
tasks[].tags[].key

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.

tasks[].tags[].value

The optional part of a key-value pair that make up a tag. A value acts as a descriptor within a tag category (key).

tasks[].task_arn

The Amazon Resource Name (ARN) of the task.

tasks[].task_definition_arn

The ARN of the task definition that creates the task.

tasks[].version

The version counter for the task. Every time a task experiences a change that starts a CloudWatch event, the version counter is incremented. If you replicate your Amazon ECS task state with CloudWatch Events, you can compare the version of a task reported by the Amazon ECS API actions with the version reported in CloudWatch Events for the task (inside the detail object) to verify that the version in your event stream is current.

failures

Any failures associated with the call.

STRUCT(
"arn" VARCHAR,
"reason" VARCHAR,
"detail" VARCHAR
)[]
Show child fields
failures[]
Show child fields
failures[].arn

The Amazon Resource Name (ARN) of the failed resource.

failures[].detail

The details of the failure.

failures[].reason

The reason for the failure.