Search code examples
amazon-web-servicesaws-cli

How to switch profiles with aws configure sso without having to clear browser cache


These are the steps I need to currently follow in order to switch profiles with aws configure sso from my terminal to use aws cli commands without credentials missing error:

  1. Set default browser to one I don't use OR clear browser cache

  2. aws configure sso --profile X (If browser cache cleared, it requests sign in and password, otherwise it seeems to default to previous signed in user)

  3. aws configure list (It hasn't set my profile, so credentials are missing!)

  4. export AWS_PROFILE="X" fixes this

  5. aws configure list ( It should now show both profile selected and credentials filled)

Now it works, but if I want to switch profile I have to go through all those steps. Is there a better way, where all I have to do is: aws configure sso --profile newprofile?

I'm using latest aws cli on windows in vscode terminal


Solution

  • The only way I solved this was:

    1. aws sso logout
    2. aws sso login --profile admin
    3. signin via browser
    4. export AWS_PROFILE="admin" (Without this step, it will not work!)

    aws sts get-caller-identity

    It still requires 4 steps, including having to export AWS_PROFILE, but at least I don't have to clear my browser cache.