Skip to content

Instantly share code, notes, and snippets.

@mims92
Last active January 30, 2020 09:42
Show Gist options
  • Save mims92/f4b3b50da9e3d651920738ef606f4b47 to your computer and use it in GitHub Desktop.
Save mims92/f4b3b50da9e3d651920738ef606f4b47 to your computer and use it in GitHub Desktop.
AWS - Bash - List all EC2 instances
#!/bin/bash
#chmod +x /usr/bin/awsec2
#Usage: awsec2 <profile-name>
aws ec2 describe-instances --profile $1 | jq -r '.[][].Instances[] | [ .InstanceId, (.Tags[]|select(.Key=="Name")|.Value), (.NetworkInterfaces[].PrivateIpAddresses[].PrivateIpAddress)] | select (.!=null) | @tsv' | column -s$'\t' -t'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment