code-dumps/aws/aws-inventory-from-awsconfig.py

17 lines
467 B
Python
Raw Normal View History

2024-03-06 09:49:46 +08:00
#!/usr/bin/env python3
import boto3
client = boto3.client('config')
resp = client.get_discovered_resource_counts()
print("ResourceType, ResourceId")
2024-03-06 09:49:46 +08:00
for item in resp['resourceCounts']:
if item['resourceType'] == "AWS::Config::ResourceCompliance":
continue
2024-03-06 09:49:46 +08:00
reslist = client.list_discovered_resources(resourceType=item['resourceType'])
for res in reslist['resourceIdentifiers']:
print(item['resourceType'], res['resourceId'], sep=', ')