Skip to content

Instantly share code, notes, and snippets.

@gmartinerro
Created October 6, 2018 10:17
Show Gist options
  • Save gmartinerro/9e9cc8d2ac35c3f113d871f861965907 to your computer and use it in GitHub Desktop.
Save gmartinerro/9e9cc8d2ac35c3f113d871f861965907 to your computer and use it in GitHub Desktop.
Shell script to get the list of EC2 instances
#!/bin/bash
aws --region eu-west-1 ec2 describe-instances \
--query 'Reservations[*].Instances[*].[InstanceId,State.Name,InstanceType,PrivateIpAddress,PublicIpAddress,Tags[?Key==`Name`].Value[]]'\
--output json | tr -d '\n[] "' | perl -pe 's/i-/\ni-/g' | tr ',' '\t' | sed -e 's/null/None/g' | grep '^i-' | column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment