Last active
August 3, 2022 09:56
-
-
Save xbalaji/2722b4ee9a7a88bfd0fdd5feeb8cf22a to your computer and use it in GitHub Desktop.
aws list resources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list all regions | |
aws ec2 describe-regions --output text | cut -f3- | |
# the use resourcegrouptaggingapi to list resources in each region | |
aws resourcegroupstaggingapi get-resources --region ${REG_NAME} | jq -r '.[][] | .ResourceARN' | |
aws resourcegroupstaggingapi get-resources --tag-filters "Key=XYZ" | jq -r '.[][] | .ResourceARN as $res | .Tags[] | select(.Key == "XYZ") | [$res, .Value ] | @csv ' | |
# display all non-us regions | |
aws ec2 describe-regions | jq -r '.Regions[] | select(.RegionName | test("^(?!(us-).*)")) | .RegionName' | |
# display all resources in non-us regions | |
aws ec2 describe-regions | jq -r '.Regions[] | select(.RegionName | test("^(?!(us-).*)")) | .RegionName' | xargs -t -L 1 -I {} aws resourcegroupstaggingapi get-resources --region {} | jq -r '.ResourceTagMappingList[].ResourceARN' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment