Skip to content

ECS

Utilities for working with Amazon Elastic Container Service.


ecs_describe_container_instances

ecs_describe_container_instances(
    container_instances, cluster, **kwargs
)

Describe ECS container instances.

Parameters:

Name Type Description Default
container_instances List[str]

List of container instance IDs or ARNs.

required
cluster str

The short name or full ARN of the cluster.

required
**kwargs

Additional arguments passed to the ECS API.

{}

Raises:

Type Description
AWSError

If the container instances cannot be described.

Returns:

Type Description
DescribeContainerInstancesResponseTypeDef

The describe container instances response.

Source code in src/aibs_informatics_aws_utils/ecs.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def ecs_describe_container_instances(
    container_instances: List[str], cluster: str, **kwargs
) -> DescribeContainerInstancesResponseTypeDef:
    """Describe ECS container instances.

    Args:
        container_instances (List[str]): List of container instance IDs or ARNs.
        cluster (str): The short name or full ARN of the cluster.
        **kwargs: Additional arguments passed to the ECS API.

    Raises:
        AWSError: If the container instances cannot be described.

    Returns:
        The describe container instances response.
    """
    ecs = get_ecs_client()
    try:
        return ecs.describe_container_instances(
            containerInstances=container_instances, cluster=cluster, **kwargs
        )
    except ClientError as e:
        msg = (
            "Error retrieving container instance metadata for container "
            f"instances={container_instances}, cluster={cluster}: {e}"
        )
        logger.error(msg, exc_info=True)
        raise AWSError(msg)