Skip to content

Instantly share code, notes, and snippets.

@instaBOT
Last active September 25, 2015 21:50
Show Gist options
  • Save instaBOT/0070bc7d45e781c6add1 to your computer and use it in GitHub Desktop.
Save instaBOT/0070bc7d45e781c6add1 to your computer and use it in GitHub Desktop.
print a list of all EC2 instances, or just 'dev' ones, or just 'prod' ones
#!/usr/bin/env bash
cd
set -e
aws ec2 describe-instances \
--query 'Reservations[*].Instances[*].[InstanceId, State.Name, Tags, LaunchTime]' --output text
# i-95da6698 2015-04-06T22:00:06.000Z
# env prod
# Name Dev 2015
# i-92353198 2015-02-07T15:22:42.000Z
# env prod
# Name Mongodb 2.6.8
# i-d2eba414 None 2015-09-23T15:55:22.000Z
# i-7a5a71bf 2015-09-16T20:54:46.000Z
# env prod
# Name ig-blog2
# i-b74549bd 2015-02-11T20:14:19.000Z
# env prod
# Name Instagis Web 2015
#!/usr/bin/env bash
cd
set -e
aws ec2 describe-instances --filters Name=tag:env,Values=dev \
--query 'Reservations[*].Instances[*].[InstanceId, State.Name, Tags, LaunchTime]' --output text
# i-a7581661 2015-09-23T19:00:01.000Z
# env dev
# i-5859179e 2015-09-23T19:05:09.000Z
# env dev
# i-0a5917cc 2015-09-23T19:05:35.000Z
# env dev
# i-ad5e106b 2015-09-23T18:53:19.000Z
# env dev
#!/usr/bin/env bash
cd
set -e
aws ec2 describe-instances --filters Name=tag:env,Values=prod \
--query 'Reservations[*].Instances[*].[InstanceId, State.Name, Tags, LaunchTime]' --output text
# i-95da6698 2015-04-06T22:00:06.000Z
# env prod
# Name Dev 2015
# i-92353198 2015-02-07T15:22:42.000Z
# env prod
# Name Mongodb 2.6.8
# i-7a5a71bf 2015-09-16T20:54:46.000Z
# env prod
# Name ig-blog2
# i-b74549bd 2015-02-11T20:14:19.000Z
# env prod
# Name Instagis Web 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment