Straight to the point

If you are a boto3 user and have multiple AWS profiles defined in your shell, I am sure that you have faced this issue at least once. Boto3 loads the default profile if you don’t specify explicitly. I am trying to explain how to specify AWS profiles while using boto3.

Lets say, we want to use the profile “dev”, We have the following ways in boto3.

1. Create a new session with the profile

1

dev=boto3.session.Session(profile_name='dev')

2. Change the profile of the default session in code

1

boto3.setup_default_session(profile_name='dev')

3. Change the profile of the default session with an environment variable