Table: aws_ecs_container_instance - Query AWS ECS Container Instance using SQL
The AWS ECS Container Instance is a resource within the Amazon Elastic Container Service (ECS). It refers to a single EC2 instance that is part of an ECS cluster, which runs containerized applications. It provides the necessary infrastructure to manage, schedule, and run Docker containers on a cluster.
Table Usage Guide
The aws_ecs_container_instance
table in Steampipe provides you with information about the Amazon Elastic Container Service (ECS) container instances. This table allows you, as a DevOps engineer, to query container-specific details, including the container instance ARN, status, running tasks count, pending tasks count, agent connected status, and more. You can utilize this table to gather insights on container instances, such as the number of running or pending tasks, the status of the agent connection, and more. The schema outlines the various attributes of the ECS container instance for you, including the instance ARN, instance type, launch type, and associated tags.
Examples
Basic info
Determine the areas in which your AWS Elastic Container Service (ECS) instances are running and their status. This can help you identify instances where there are pending tasks, providing insights for potential performance improvement.
select arn, ec2_instance_id, status, status_reason, running_tasks_count, pending_tasks_countfrom aws_ecs_container_instance;
select arn, ec2_instance_id, status, status_reason, running_tasks_count, pending_tasks_countfrom aws_ecs_container_instance;
List container instances that have failed registration
Determine the areas in which container instances have failed to register within the AWS ECS service. This is useful in diagnosing and resolving issues that could potentially disrupt your application's performance or availability.
select arn, status, status_reasonfrom aws_ecs_container_instancewhere status = 'REGISTRATION_FAILED';
select arn, status, status_reasonfrom aws_ecs_container_instancewhere status = 'REGISTRATION_FAILED';
Get details of resources attached to each container instance
Explore which resources are linked to each container instance in AWS ECS to better manage and track resources. This can help in identifying any potential issues or inefficiencies in resource allocation.
select arn, attachment ->> 'id' as attachment_id, attachment ->> 'status' as attachment_status, attachment ->> 'type' as attachment_typefrom aws_ecs_container_instance, jsonb_array_elements(attachments) as attachment;
select arn, json_extract(attachment.value, '$.id') as attachment_id, json_extract(attachment.value, '$.status') as attachment_status, json_extract(attachment.value, '$.type') as attachment_typefrom aws_ecs_container_instance, json_each(attachments) as attachment;
List container instances with using a given AMI
Determine the areas in which specific Amazon Machine Images (AMIs) are being used within your container instances. This is particularly useful for identifying potential security risks or for troubleshooting purposes.
select arn, setting ->> 'Name' as name, setting ->> 'Value' as valuefrom aws_ecs_container_instance, jsonb_array_elements(attributes) as settingwhere setting ->> 'Name' = 'ecs.ami-id' and setting ->> 'Value' = 'ami-0babb0c4a4e5769b8';
select arn, json_extract(setting.value, '$.Name') as name, json_extract(setting.value, '$.Value') as valuefrom aws_ecs_container_instance, json_each(attributes) as settingwhere json_extract(setting, '$.Name') = 'ecs.ami-id' and json_extract(setting, '$.Value') = 'ami-0babb0c4a4e5769b8';
Schema for aws_ecs_container_instance
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The AWS Account ID in which the resource is located. |
agent_connected | boolean | True if the agent is connected to Amazon ECS. | |
agent_update_status | text | The status of the most recent agent update. | |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
arn | text | The namespace Amazon Resource Name (ARN) of the container instance. | |
attachments | jsonb | The resources attached to a container instance, such as elastic network interfaces. | |
attributes | jsonb | The attributes set for the container instance. | |
capacity_provider_name | text | The capacity provider associated with the container instance. | |
cluster_arn | text | The ARN of the cluster. | |
ec2_instance_id | text | The EC2 instance ID of the container instance. | |
health_status | jsonb | An object representing the health status of the container instance. | |
partition | text | The AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov). | |
pending_tasks_count | bigint | The number of tasks on the container instance that are in the PENDING status. | |
region | text | The AWS Region in which the resource is located. | |
registered_at | timestamp with time zone | The Unix timestamp for when the container instance was registered. | |
registered_resources | jsonb | CPU and memory that can be allocated on this container instance to tasks. | |
remaining_resources | jsonb | CPU and memory that is available for new tasks. | |
running_tasks_count | bigint | CPU and memory that is available for new tasks. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
status | text | The status of the container instance. | |
status_reason | text | The reason that the container instance reached its current status. | |
tags | jsonb | A map of tags for the resource. | |
title | text | Title of the resource. | |
version | bigint | The reason that the container instance reached its current status. | |
version_info | jsonb | Version information for the Amazon ECS container agent and Docker daemon running on the container instance. |
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_container_instance