Skip to content

Instantly share code, notes, and snippets.

@chemar
Created March 3, 2017 18:33
Show Gist options
  • Save chemar/8343f822eba39286b6d42ed3ad436848 to your computer and use it in GitHub Desktop.
Save chemar/8343f822eba39286b6d42ed3ad436848 to your computer and use it in GitHub Desktop.
AWS EC2 list volumes and attributes using boto3
import boto3
ec2 = boto3.resource('ec2')
volume_iterator = ec2.volumes.all()
for v in volume_iterator:
for a in v.attachments:
print "{0} {1} {2}".format(v.id, v.state, a['InstanceId'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment