Skip to content

Instantly share code, notes, and snippets.

@cpuspellcaster
Created May 5, 2017 19:47
Show Gist options
  • Select an option

  • Save cpuspellcaster/7d00698301c8f47e5d14d03c1216bf0a to your computer and use it in GitHub Desktop.

Select an option

Save cpuspellcaster/7d00698301c8f47e5d14d03c1216bf0a to your computer and use it in GitHub Desktop.
Query all ECS instances and get output of 'docker ps'
#! /usr/bin/env bash
IP_ADDRS=$(
aws --profile prod ec2 describe-instances \
--filters \
"Name=tag:Environment,Values=prod" \
"Name=tag:Name,Values=blackbird_microservices" \
"Name=instance-state-name,Values=running" \
--query "Reservations[*].Instances[*].PrivateIpAddress" \
--output text
)
for IP_ADDR in $IP_ADDRS; do
echo " === $IP_ADDR ==="
ssh ec2-user@$IP_ADDR docker ps
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment