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

2. Change the profile of the default session in code

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

We can also list the available profiles defined in our configuration

Reference : https://stackoverflow.com/questions/33378422/how-to-choose-an-aws-profile-when-using-boto3-to-connect-to-cloudfront