Search code examples
amazon-web-servicesswitch-statementboto3profileconfigure

Switching between AWS accounts


I am using boto3 in VSCode for some automation in AWS. I have a default profile(which is my own) configured using "aws configure". Now I want to switch from my personal account to my company profile and have used the same command again to change the configuration. The problem is the configuration changed and is reflected in the config file but I cannot access my company profile as my personal account is still active even after the change. Is there a way to switch between accounts without this problem? enter image description here


Solution

  • for some reasons you have values in environment variables - they override the values from profile (see env from Type column). This is what I get:

    PS C:\> aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
      profile                <not set>          None    None
    access_key     ****************GOCJ shared-credentials-file
    secret_key     ****************DMq1 shared-credentials-file
    region                us-west-2      config-file    ~/.aws/config
    
    PS C:\> aws configure list --profile govcloud
      Name                    Value             Type    Location
      ----                    -----             ----    --------
      profile                 govcloud          manual    --profile
    access_key     ****************YXPK shared-credentials-file
    secret_key     ****************J/77 shared-credentials-file
    region            us-gov-west-1      config-file    ~/.aws/config
    

    note, shared-credentials-file where you have env