Sub topic 2
Letting `aws configure sso` Write the Configuration
Assume AWS CLI version 2 is installed and IAM Identity Center has assigned you a permission set in an AWS account. The wizard creates an sso-session block and a named profile in ~/.aws/config.
Run the Configuration Wizard
Start the wizard:
aws configure ssoEnter a session name, IAM Identity Center start URL, SSO Region, and registration scope when prompted. The browser then opens for authorization. Choose an AWS account, permission set, default Region, and profile name.
The resulting configuration resembles this:
[sso-session my-sso]
sso_start_url = https://example.awsapps.com/start
sso_region = us-east-1
sso_registration_scopes = sso:account:access
[profile dev]
sso_session = my-sso
sso_account_id = 111122223333
sso_role_name = ReadOnlyAccess
region = us-west-2A second profile can reuse my-sso for another account. The profile identifies the account and role. The shared session identifies the sign-in portal.
Sign In and Verify the Identity
Authorize the CLI in your browser:
aws sso login --profile devThe CLI caches the sign-in token and retrieves temporary role credentials as needed. Confirm the account and role before making changes:
aws sts get-caller-identity --profile devThe output includes the account ID and an assumed-role ARN. This check catches a common error: signing in successfully but using the wrong account or profile.
>callout note > Always run get-caller-identity when switching accounts. A valid session does not prove that it is the session you intended to use.
Select Profiles and Resolve Credentials
Use --profile for one command:
aws s3 ls --profile devOr set the profile for the current shell:
export AWS_PROFILE=dev
aws s3 lsThe CLI checks explicit settings first, then environment variables, then the selected profile's configuration and cached SSO credentials. A command-line --profile overrides AWS_PROFILE. Avoid exporting unrelated static access keys, because environment credentials can take precedence over the SSO profile.
Exercise
Which command verifies that the dev profile points to the intended AWS account?
Show answer
aws sts get-caller-identity --profile dev