Skip to content

Instantly share code, notes, and snippets.

@mihow
Forked from GitToby/list-aws-resource.py
Created November 14, 2025 21:14
Show Gist options
  • Select an option

  • Save mihow/1070c3ebd6e614a679dc07d420e442aa to your computer and use it in GitHub Desktop.

Select an option

Save mihow/1070c3ebd6e614a679dc07d420e442aa to your computer and use it in GitHub Desktop.
Using Boto, list all resources in an AWS account
# /// script
# https://peps.python.org/pep-0723/
# dependencies = [
# "boto3"
# ]
# ///
import boto3
from botocore.exceptions import ClientError
# uses the currently configured profile or "default"
session = boto3.Session()
regions = session.get_available_regions("ec2")
for region in regions:
print(region)
try:
client = session.client("resourcegroupstaggingapi", region_name=region)
for resource in client.get_resources().get("ResourceTagMappingList"):
print(" - ",resource["ResourceARN"])
for t in resource["Tags"]:
k,v = t.values()
print(f" > {k} = {v}")
except ClientError as e:
print(f"Could not connect to region with error: {e}")
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment