Created
March 2, 2021 07:42
-
-
Save Satak/9cfff5157049a82fe3b8073e5849c13d to your computer and use it in GitHub Desktop.
AWS Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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