steampipe plugin install aws

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_count
from
aws_ecs_container_instance;
select
arn,
ec2_instance_id,
status,
status_reason,
running_tasks_count,
pending_tasks_count
from
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_reason
from
aws_ecs_container_instance
where
status = 'REGISTRATION_FAILED';
select
arn,
status,
status_reason
from
aws_ecs_container_instance
where
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_type
from
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_type
from
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 value
from
aws_ecs_container_instance,
jsonb_array_elements(attributes) as setting
where
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 value
from
aws_ecs_container_instance,
json_each(attributes) as setting
where
json_extract(setting, '$.Name') = 'ecs.ami-id'
and json_extract(setting, '$.Value') = 'ami-0babb0c4a4e5769b8';

Schema for aws_ecs_container_instance

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
account_idtext=, !=, ~~, ~~*, !~~, !~~*The AWS Account ID in which the resource is located.
agent_connectedbooleanTrue if the agent is connected to Amazon ECS.
agent_update_statustextThe status of the most recent agent update.
akasjsonbArray of globally unique identifier strings (also known as) for the resource.
arntextThe namespace Amazon Resource Name (ARN) of the container instance.
attachmentsjsonbThe resources attached to a container instance, such as elastic network interfaces.
attributesjsonbThe attributes set for the container instance.
capacity_provider_nametextThe capacity provider associated with the container instance.
cluster_arntextThe ARN of the cluster.
ec2_instance_idtextThe EC2 instance ID of the container instance.
partitiontextThe AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov).
pending_tasks_countbigintThe number of tasks on the container instance that are in the PENDING status.
regiontextThe AWS Region in which the resource is located.
registered_attimestamp with time zoneThe Unix timestamp for when the container instance was registered.
registered_resourcesjsonbCPU and memory that can be allocated on this container instance to tasks.
remaining_resourcesjsonbCPU and memory that is available for new tasks.
running_tasks_countbigintCPU and memory that is available for new tasks.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
statustextThe status of the container instance.
status_reasontextThe reason that the container instance reached its current status.
tagsjsonbA map of tags for the resource.
titletextTitle of the resource.
versionbigintThe reason that the container instance reached its current status.
version_infojsonbVersion 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