1 Answer
- Newest
- Most votes
- Most comments
0
I don't think there is going to be any pre-built metrics that can do this for you. Two ways that I can think of that might help here:
- This is probably simplest: Use Config - you can create a query to list all of the instances, then filter from there: https://docs.aws.amazon.com/config/latest/developerguide/example-query.html
- Create a Lambda function that scans all regions and collects the data that you need. Run the function periodically using EventBridge then store the results in an appropriate place. This is more complex but depending on what you're looking for may have greater flexibility. Example Python code below:
import boto3
ec2 = boto3.client('ec2')
regionList = ec2.describe_regions()['Regions']
for region in regionList:
regionName = region['RegionName']
ec2Region = boto3.client('ec2', region_name=regionName)
ec2Iterator = ec2Region.get_paginator('describe_instances').paginate()
for object in ec2Iterator:
for instanceList in object['Reservations']:
for instance in instanceList['Instances']:
print(regionName, instance['InstanceType'])
Relevant content
- asked 2 years ago
- asked 5 years ago
- asked 3 years ago
- Accepted Answerasked 9 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 10 months ago