What Does `aws sso login` Do?

Getting your AWS credentials for the CLI.

AWSAWS CLI

The AWS CLI is the “Amazon Web Services Command Line Interface”. It lets you access your AWS resources through a terminal. To use your AWS resources, you need to log on with your SSO credentials. First, you have to configure them, which AWS tell you about here:

Configure the AWS CLI to use IAM Identity Center token provider credentials with automatic…

Once you’ve got them, you use this command to login:

css
aws sso login --profile your-aws-profile-here

Replacing the your-aws-profile-here with the profile you’ve created. The first time I did this I thought this logged me into a separate shell. But it doesn’t. Here’s what actually happens.

Call the IAM Identity Center

The AWS CLI calls your portal location and requests a credential from the IAM Identity Center. A page loads in your browser asking you to confirm the request and to sign in — if you haven’t already.

Save the credential

Once you’ve signed in, an IAM access token is returned. The token is cached on your computer, and is normally valid for a few hours. The token is associated with the profile your provided: your-aws-profile-here.

Using the credential

To use it, you end your AWS commands with the profile flag:

bash
aws s3 ls --profile your-aws-profile-here

The reference for the AWS login command is below:

login - AWS CLI 2.16.8 Command Reference