I'm trying to retrieve all the volumes associated with an instance.
if volume.attachment_state() == 'attached':
volumesinstance = ec2_connection.get_all_instances()
ids = [z for k in volumesinstance for z in k.instances]
for s in ids:
try:
tags = s.tags
instance_name = tags["Name"]
print (instance_name)
except Exception as e:
print e
However, it's not working as intended.
You can add filters in get_all_instances method
like this: