Skip to content

Instantly share code, notes, and snippets.

@Satak
Created March 2, 2021 07:42
Show Gist options
  • Save Satak/9cfff5157049a82fe3b8073e5849c13d to your computer and use it in GitHub Desktop.
Save Satak/9cfff5157049a82fe3b8073e5849c13d to your computer and use it in GitHub Desktop.
AWS Python
import boto3
from pprint import pprint
ec2 = boto3.resource('ec2', 'eu-west-1')
vms = ec2.instances.all()
for vm in vms:
o = {
'id': vm.id,
'state': vm.state['Name'],
'name': next(tag['Value'] for tag in vm.tags if tag['Key'] == 'Name')
}
pprint(o, indent=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment