I am trying to get volume-id list of aws instance using boto 3, I am getting sort of collection manager but I don't know how to get the data inside.
import boto3
ec2 = boto3.resource('ec2', region_name='us-west-2')
instance = ec2.Instance('i-xxxxxx')
volumes = instance.volumes.all()
print volumes
The answer I got is:
ec2.Instance.volumesCollection(ec2.Instance(id='i-xxxxxx'), ec2.Volume)
How I am using the "ec2.Volume" to get the volume id
Thanks, Cfir.
It's just an iterable of objects so
for v in volumes:
print(v.id)
if you want to get a list of id :
l = [v.id for v in volumes]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With