Change between local AWS profile

We can store AWS profile data in a configuration file under C:\Users\{userName}\.aws\credentials like following:

[profile1]
aws_access_key_id=x
aws_secret_access_key=y
region=eu-west-1
aws_region=eu-west-1

[profil2]
aws_access_key_id=xy
aws_secret_access_key=zk
region=eu-west-1
aws_region=eu-west-1

We can easily rotate between them using the following command:

setx AWS_PROFILE profil1

To see which profile is currently selected use this code:

aws configure list

Note: As the above logic uses environment variable to save and read the currently selected profile, we need to restart applications to the update take effect.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.