Skip to content

Instantly share code, notes, and snippets.

@rcbop
Created July 25, 2018 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcbop/3e68553fe7f42c437db684d48dd2fab7 to your computer and use it in GitHub Desktop.
Save rcbop/3e68553fe7f42c437db684d48dd2fab7 to your computer and use it in GitHub Desktop.
finds instances in ec2 without Owner label in all regions
#!/bin/bash
for region in $(aws ec2 describe-regions --output text | cut -f3); do
echo "REGIÃO -> $region"
aws ec2 describe-instances \
--query 'Reservations[].Instances[?!not_null(Tags[?Key == `Owner`].Value)].{PUBLICIP:PublicIpAddress,EC2ID:InstanceId,TYPE:InstanceType,STATE:State.Name,TAGS:Tags[*].{Key:Key,Value:Value}} | []' --region $region | jq '.'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment