multiple credentials in .boto file - how to use them?

797 views
Skip to first unread message

Tid

unread,
Mar 14, 2014, 11:11:59 AM3/14/14
to boto-...@googlegroups.com
Hi Folks, 

I have a few different AWS EC2 accounts and have the following setup : 

.boto : 
===================================
 [fred]
aws_access_key_id = xxxx
aws_secret_access_key = xxxx

[bill]
aws_access_key_id= yyy
aws_secret_access_key = yyyyy

[eric]
aws_access_key_id=zzz
aws_secret_access_key = zzz

====================================

if I have a single stanza [Credentials], the following code connects fine, but how do I connect using individual credentials? 

===========================================
rr = [ boto.ec2.get_region('eu-west-1') for x in regions ]
for reg in rr:
  conn = reg.connect()
  reservations = conn.get_all_instances()
  for r in reservations:
    for i in r.instances:
      print i
===========================================

do I use some variant of 

  reg.connect([eric])

?

cheers, 

Tid

Adrian Klaver

unread,
Mar 14, 2014, 12:47:29 PM3/14/14
to boto-...@googlegroups.com
reg.connect(profile_name="eric")

Assuming you are using boto >= 2.24.

>
> ?
>
> cheers,
>
> Tid
>


--
Adrian Klaver
adrian...@aklaver.com

Tid

unread,
Apr 2, 2014, 4:22:34 AM4/2/14
to boto-...@googlegroups.com
Sorted now. PBKAC. The .boto file should be of the form: 

==================================================================
# me
[profile tid]
aws_access_key_id = xxx
aws_secret_access_key = yyy

# test env
[profile test]
aws_access_key_id=yyy
aws_secret_access_key = zzz
===================================================================

(i.e you need the word 'profile' at the start of each profile stanza. Doh! ) 


Reply all
Reply to author
Forward
0 new messages