A Python script that scans AWS resources across all regions for specific tag patterns and provides a detailed inventory of tagged resources.
This tool helps AWS administrators and developers to:
- Search for resources with specific tag patterns across all AWS regions
- List all found resources with their ARNs
- Provide a total count of resources matching the tag pattern
- Support for all AWS resource types that allow tagging
- Python 3.6 or higher
- AWS CLI configured with appropriate credentials
- Required Python packages:
- boto3
- botocore
The AWS user/role running this script needs the following permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"tag:GetResources",
"resource-groups:SearchResources",
"ec2:DescribeRegions"
],
"Resource": "*"
}
]
}
- Install required packages:
pip install boto3 botocore
- Configure AWS credentials:
aws configure
- Run the script:
python aws_resource_tag_scanner.py
-
When prompted, enter the tag pattern you want to search for (e.g., 'Environment', 'Project', etc.)
-
The script will:
- Search through all AWS regions
- List all resources with matching tags
- Display a total count at the end
Example output:
Enter the tag pattern to search for (e.g., 'Environment'): Project
Searching in region: us-east-1
Searching in region: us-west-2
...
Resources found:
- arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0
- arn:aws:s3:::my-bucket
...
Total resources found: 42
- Cross-region resource scanning
- Support for all taggable AWS resources
- Paginated results handling
- Error handling for API calls
- User-friendly output format
- The script requires appropriate AWS permissions to scan resources
- Scanning all regions may take some time depending on the number of resources
- API rate limiting may affect large-scale scans
The script includes error handling for common issues:
- Invalid AWS credentials
- Insufficient permissions
- API throttling
- Network connectivity issues