capsule.adrianhesketh.com

home

AWS CLI - authenticating with SSO

AWS CLI v1 didn't support AWS SSO, but the new AWS CLI does. Before this, you had to do a complicated dance of configuration, or use a tool to save yourself the trouble.

Prior to AWS CLI v2 being released, I used the SSOFresh tool: [0] which took away the complication of the various command line incantations that were required without it.

[0]

So, how do you migrate if you're using that now that it's built in to the CLI?

First, upgrade your AWS CLI. [1]

[1]

I use a relatively niche package manager call Nix [2], so the instructions don't apply to me. If you happen to use it too, then you'll find that the `awscli` package is V1, while `awscli2` is V2. You can run AWS CLI v2 without affecting your system by using `nix-shell` or you can update your system.

[2]

You can check your version in your shell:

With the latest version installed, I needed to take my SSOFresh configuration (`ssofresh.ini`) and migrate it over to `~/.aws/config`.

My SSOFresh configuration looked like:

Then I used the guide here to configure `~/.aws/config` instead [3]

[3]

Next, I needed to use the CLI to login.

A Web browser popped open and asked me to login. Easy! Then, I went back to the shell and tried it out.

Great it worked, I saw a list of all my log groups. Of course, it's annoying to have to remember to add the `--profile` parameter, so I ran `export AWS_PROFILE=company-dev` so I could skip it.

Finally, to logout...

If you get this error, (or logging out) you'll need to login (`aws sso login`) again.

More

Next

Setting up AppSync GraphQL subscriptions with TypeScript and CDK

Previous

Running DynamoDB Local with nix

Home

home