Table: aws_ecs_task - Query AWS ECS Tasks using SQL
AWS Elastic Container Service (ECS) Tasks are a running instance of an Amazon ECS task. They are a scalable unit of computing that contain everything needed to run an application on Amazon ECS. ECS tasks can be used to run applications on a managed cluster of Amazon EC2 instances.
Table Usage Guide
The aws_ecs_task
table in Steampipe provides you with information about tasks within Amazon Elastic Container Service (ECS). This table enables you, as a DevOps engineer, to query task-specific details, including the current task status, task definition, associated cluster, and other metadata. You can utilize this table to gather insights on tasks, such as tasks that are running, stopped, or pending, tasks associated with specific clusters, and more. The schema outlines the various attributes of the ECS task for you, including the task ARN, last status, task definition ARN, and associated tags.
Examples
Basic info
Determine the status and launch type of tasks within your AWS Elastic Container Service (ECS) to manage and optimize your ECS resources effectively. This can help in maintaining the desired state of your tasks and ensuring they are running as expected.
select cluster_name, desired_status, launch_type, task_arnfrom aws_ecs_task;
select cluster_name, desired_status, launch_type, task_arnfrom aws_ecs_task;
List task attachment details
This query is useful for gaining insights into the status and types of attachments associated with specific tasks within a cluster. This can help in managing and troubleshooting tasks effectively in a real-world scenario.
select cluster_name, task_arn, a ->> 'Id' as attachment_id, a ->> 'Status' as attachment_status, a ->> 'Type' as attachment_type, jsonb_pretty(a -> 'Details') as attachment_detailsfrom aws_ecs_task, jsonb_array_elements(attachments) as a;
select cluster_name, task_arn, json_extract(a.value, '$.Id') as attachment_id, json_extract(a.value, '$.Status') as attachment_status, json_extract(a.value, '$.Type') as attachment_type, json(a.value, '$.Details') as attachment_detailsfrom aws_ecs_task, json_each(attachments) as a;
List task protection details
Explore the protection status and expiry dates of tasks within your AWS ECS clusters. This can help ensure all tasks are adequately protected and any expiring protections are promptly renewed.
select cluster_name, task_arn, protection ->> 'ProtectionEnabled' as protection_enabled, protection ->> 'ExpirationDate' as protection_expiration_datefrom aws_ecs_task;
select cluster_name, task_arn, json_extract(protection, '$.ProtectionEnabled') as protection_enabled, json_extract(protection, '$.ExpirationDate') as protection_expiration_datefrom aws_ecs_task;
Query examples
Schema for aws_ecs_task
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The AWS Account ID in which the resource is located. |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
attachments | jsonb | The Elastic Network Adapter associated with the task if the task uses the awsvpc network mode. | |
attributes | jsonb | The attributes of the task. | |
availability_zone | text | The availability zone of the task. | |
capacity_provider_name | text | The capacity provider associated with the task. | |
cluster_arn | text | The ARN of the cluster that hosts the task. | |
cluster_name | text | A user-generated string that you use to identify your cluster. | |
connectivity | text | The connectivity status of a task. | |
connectivity_at | timestamp with time zone | The Unix timestamp for when the task last went into CONNECTED status. | |
container_instance_arn | text | = | The ARN of the container instances that host the task. |
containers | jsonb | The containers associated with the task. | |
cpu | bigint | The number of CPU units used by the task as expressed in a task definition. | |
created_at | timestamp with time zone | The Unix timestamp for when the task was created. | |
desired_status | text | = | The desired status of the task. |
enable_execute_command | boolean | Whether or not execute command functionality is enabled for this task. If true, this enables execute command functionality on all containers in the task. | |
ephemeral_storage | jsonb | The ephemeral storage settings for the task. | |
execution_stopped_at | timestamp with time zone | The Unix timestamp for when the task execution stopped. | |
group | text | The name of the task group associated with the task. | |
health_status | text | The health status for the task, which is determined by the health of the essential containers in the task. If all essential containers in the task are reporting as HEALTHY, then the task status also reports as HEALTHY. | |
inference_accelerators | jsonb | The Elastic Inference accelerator associated with the task. | |
last_status | text | The last known status of the task. | |
launch_type | text | = | The infrastructure on which your task is running. |
memory | bigint | The amount of memory (in MiB) used by the task as expressed in a task definition. | |
overrides | jsonb | One or more container overrides. | |
partition | text | The AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov). | |
platform_family | text | The operating system that your tasks are running on. | |
platform_version | text | The platform version on which your task is running. | |
protection | jsonb | Protection status of task in an Amazon ECS service. | |
pull_started_at | timestamp with time zone | The Unix timestamp for when the container image pull began. | |
pull_stopped_at | timestamp with time zone | The Unix timestamp for when the container image pull completed. | |
region | text | The AWS Region in which the resource is located. | |
service_name | text | = | The name of the service. |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
started_at | timestamp with time zone | The Unix timestamp for when the task started. | |
started_by | text | The tag specified when a task is started. | |
stop_code | text | The stop code indicating why a task was stopped. | |
stopped_at | timestamp with time zone | The Unix timestamp for when the task was stopped. | |
stopped_reason | text | The reason that the task was stopped. | |
stopping_at | timestamp with time zone | The Unix timestamp for when the task stops. | |
tags | jsonb | A map of tags for the resource. | |
tags_src | jsonb | A list of tags associated with task. | |
task_arn | text | The Amazon Resource Name (ARN) of the task. | |
task_definition_arn | text | The ARN of the task definition that creates the task. | |
version | bigint | The version counter for the task. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- aws
You can pass the configuration to the command with the --config
argument:
steampipe_export_aws --config '<your_config>' aws_ecs_task