0

I'm new to Python/Boto3.

I would like to manage AWS using python.

I'm unable to find details on all available python functions of methods to manage AWS.

Example:

import boto3

ebs=boto3.resource('ec2')
vols=ebs.volumes.all()
for vol in vols:
    print vol.id

The above code works well but I'm trying to understand what is id in 'vol.id 'is it attribute of vol ? and where to find all available attributes that are valid to go with 'print vol.*'

How do I know that in 'vols=ebs.volumes.all()' all() is valid to use with volumes and what other options are available ?

I have tried using boto3 documentation but struggling.

Any help on this would be greatly appreciated.

Cheers,

2
  • How to get type hinting to work so I can see the available method calls and return types. I'm using PyCharm Commented Nov 30, 2016 at 4:31
  • You need to understand AWS services/infra to understand each Boto3 functionality. For quick start, playing AWS CLI first before dig yourself into boto3 (when you have poor understanding of each parameters). Commented Nov 30, 2016 at 16:25

2 Answers 2

1

If you want to print all attributes associated with vol, try these code

import boto3

ebs = boto3.resource('ec2')
vols = ebs.volumes.all()

for vol in vols:
    print vol.__dict__

This will print all the properties associated with volume.

Hope it helps !!

Sign up to request clarification or add additional context in comments.

1 Comment

It worked for me. Think you forgot to mention you needed snapshot id's in question
0

Just like an instance id the Volumes also have identifiers, so this line "print vol.id" is printing the list of volume identifiers(since in a loop). You can use this ID to look for the volume. For example in the console under EC2>> Volumes>> when to type the ID in search it provides you the volume details.

all() - as the doucmentation says "Creates an iterable resources in the collection". This is just getting the list of all available volumes corresponding to ebs(elastic block storage). Another example :volume.snapshots.all()

This displays all the snapshots associated with a particular volume.

Hope this helps...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.