Skip to content

Instantly share code, notes, and snippets.

@skyzyx
Created September 15, 2018 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyzyx/75c686d29e9749ccc06033f2b571b282 to your computer and use it in GitHub Desktop.
Save skyzyx/75c686d29e9749ccc06033f2b571b282 to your computer and use it in GitHub Desktop.
Check the launch status of the underlying EC2 instances in an ECS cluster.
##
# Requires:
# * AWS Unified CLI Tools
# * jq
##
cluster_name="name-of-ecs-cluster"
aws ec2 describe-instance-status \
--instance-ids $(
aws ecs describe-container-instances \
--cluster $cluster_name \
--container-instances $(
aws ecs list-container-instances \
--cluster $cluster_name \
| jq -r ".containerInstanceArns[]"
) \
| jq -r ".containerInstances[].ec2InstanceId"
) \
| jq -r '.InstanceStatuses[] | {
"id": .InstanceId,
"state": .InstanceState.Name,
"statusCheck1": .InstanceStatus.Status,
"statusCheck2": .SystemStatus.Status
}' \
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment