Using aws profiles in python2 boto


I’d like my python script (connecting to aws) to use aws profiles from ~/.aws/credentials

So, I have ~/.aws/credentials file:

My python code

The output is

So, it doesn’t seem to take the profile from the config. The region is wrong.

What am I missing?

Thank you.

===== UPDATE =====

I have a ~/.aws/config file too which looks like

===== UPDATE =====

apparently, it takes connection details.. but not region. So, if I do

I can get a list of the instances.

So, the problem is how to get the default ‘region’ from AWS config/credentials.


The credentials file is supposed to be used only for credentials. If you want to supply other attributes for your profiles you should do that in the ~/.aws/config file. So, in your case you would create a config file containing:

Leave a Reply