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.