1

Having a problem using boto to list any Elastic IPs. So far, have been pretty successful in getting back a list of instances, and performing certain operations with them. However, not really sure how to get a list/dictionary back of all eips allocated...

I see the following object: cl = botoEC2.get_all_addresses, which does not seem to return much interesting.

Any help would be greatly appreciated

Thanks!

Cmag
  • 14,946
  • 25
  • 89
  • 140

1 Answers1

5

get_all_addresses works for me. It returns a list of address objects which have various methods and attributes.

addrs = conn.get_all_addresses()
for a in addrs:
    print a.public_ip

Prints out all the eips, associated and not associated, that I have on my account.

When I'm trying to figure out the AWS api I always fire up an IPython shell and put their tab completion to good use. It's great for finding your way around.

Chris B.
  • 85,731
  • 25
  • 98
  • 139
aychedee
  • 24,871
  • 8
  • 79
  • 83
  • We do have fairly decent API docs, too. See http://boto.readthedocs.org/en/latest/ref/ec2.html#boto.ec2.connection.EC2Connection.get_all_addresses. Always room for improvement, of course, but lots of info there. But I usually use the IPython approach, too. – garnaat Oct 19 '12 at 13:20
  • Your docs are fine! But I just find it easier to play directly with a live connection. Nothing beats playing with something to see exactly how it works. – aychedee Oct 19 '12 at 14:54
  • Guys, tab completion does not seem to be available inside a for loop in ipython... Do you guys first write out the for loop? or how do you get the actual objects? – Cmag Oct 19 '12 at 20:27
  • Well, to get an object from a list just do `a = addrs[0]`. Then you can inspect `a`. – aychedee Oct 20 '12 at 02:14
  • Hello, sorry, Is the solution above possible with IAM user credentials? – jmdev Apr 23 '16 at 00:35
  • As long as the IAM user has the relevant permissions. Then yes. It should work. You'll get quite elaborate error messages as well – aychedee Apr 23 '16 at 02:37