API resource groups tagging

Sometimes you need a list of all ressoures in your AWS account. For this use case, you can use the API operations resource groups tagging.

Following command will list all resources in region Frankfurt with tag names:

aws resourcegroupstaggingapi get-resources --region eu-central-1 --output json

To get all resources across all regions, you need to run the above command in a loop with region name as parameter.

Create script get-resources.sh

#!/bin/bash

for region in `aws ec2 describe-regions --region us-east-1 --output text | cut -f4`

do
echo -e "\nListing Instances in '$region' region..."
aws resourcegroupstaggingapi get-resources --region $region
done

This allows you to see the overall resources without having to check for each region and each service.

Run the script

export AWS_PROFILE=xxxx
./get-resources.sh 

Notes

Not all resources can have tags. For a lists of resources that you can tag, see Supported Resources in the AWS Resource Groups and Tag Editor User Guide.