List all resources in an AWS account using AWS cli

Is it possible to list all resources in AWS account using AWS cli?

No. There is no direct method or command for that. But there is a workaround for that. In this post I’m gonna show you how to list all resources in an AWS account.

In AWS console, we can see all resources in a region using Tag Editor. We can do the same with aws cli. The command for this is:

aws resourcegroupstaggingapi get-resources --region us-east-1

The above command will list all resources in North Virginia region with tag names.

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

The script would look like

#!/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

Post navigation

Alvin Jaison

Myself Alvin Jaison. I'm a DevOps Engineer by Profession; A Mountaineer by Passion. I started this website to share DevOps related posts. Post your suggestions as a comment. You can reach me @ alvinjaison@outlook.com

One thought on “List all resources in an AWS account using AWS cli

Leave a Reply

Your email address will not be published. Required fields are marked *