0
votes

Is there a way to list

  • all your ecs clusters
  • the ec2 instance(s) comprising each cluster?

The aws cli does not seem to support such option.

I am trying to create an inventory of such resources and I want the above info to be recorded (ECS clusters + instance number / type of each of those instances)

1

1 Answers

3
votes

Do you have the latest AWS CLI installed so you have ecs subcommand available?

  • how to list available cluster - it will return a list of clusters ARNs:

    aws ecs list-clusters
    
  • how to get container instances of the cluster - it will return a list of container instances ARNs in the cluster:

    aws ecs list-container-instances --cluster FOOBAR
    
  • finally, how to get EC2 instance(s) ID of the container instance(s):

    aws ecs describe-container-instances --cluster FOOBAR --container-instances FOOBAR_CLUSTER_CONTAINER_INSTANCES_ARNS
    

The last command will describe particular container instance(s) where you can filter out ec2InstanceId parameter to find out EC2 instance(s) ID.