Skip to content

Instantly share code, notes, and snippets.

@chrisdpa-tvx
Last active July 28, 2017 14:02
Show Gist options
  • Save chrisdpa-tvx/b72828368eee8a94ba874ede075d0d5e to your computer and use it in GitHub Desktop.
Save chrisdpa-tvx/b72828368eee8a94ba874ede075d0d5e to your computer and use it in GitHub Desktop.
set -exu
SPOTFLEETREQ=$1
CLUSTER=$2
AZ=$3
fleet_sz=$(aws ec2 describe-spot-fleet-instances --spot-fleet-request-id ${SPOTFLEETREQ} | jq -r '.ActiveInstances|length')
container_sz=$(aws ecs list-container-instances --cluster ${CLUSTER} | jq -r '.containerInstanceArns[]' | \
xargs -n10 -J % aws ecs describe-container-instances --cluster ${CLUSTER} --container-instances % | \
jq -r ".containerInstances[].attributes[]|select(.name==\"ecs.availability-zone\" and .value==\"${AZ}\")|.value"|wc -l | xargs)
if (( fleet_sz == container_sz )); then
exit 0
fi;
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment