Sub topic 5
Letting aws configure sso write the configuration
This chapter assumes you have AWS CLI version 2 installed, know what an IAM role is, and have an IAM Identity Center user with at least one assigned permission set. The previous chapter showed the sso-session and profile blocks by hand. The wizard writes those blocks for you and checks them against your real accounts and roles.
What the wizard does
aws configure sso asks a few questions, opens your browser so you can authorize the CLI, and then writes the result to ~/.aws/config. Because it signs you in during setup, it can list the accounts and roles you are allowed to use. You pick from that list and don't have to type account IDs.
aws configure sso
# Prompts for a session name, start URL, SSO region and registration scopes,
# opens a browser to authorize, then asks you to pick an account, a role,
# a default region and a profile name.Walking through the prompts
The wizard asks for these values in order:
- SSO session name. A label of your choice, such as
my-sso. It becomes the name of the[sso-session]block. - SSO start URL. The address of your AWS access portal, for example
https://example.awsapps.com/start. Your Identity Center administrator can give you this. - SSO region. The region where your Identity Center instance lives. It is often different from the region where you run workloads.
- SSO registration scopes. Enter
sso:account:accessto let the CLI list accounts and roles and get role credentials. - Browser authorization. The CLI opens a page. Confirm the code shown and approve the request.
- Account and role. The wizard lists the accounts and permission sets assigned to you. Pick one of each.
- Default region, output format and profile name. The region and output format apply to commands run with this profile. Choose a profile name that describes the account, such as
dev.
What it writes
After you answer the prompts, ~/.aws/config contains a session block and a profile block that points to it. For the dev account, the result looks like the configuration from the previous chapter:
[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-2Note that the file section is named [sso-session my-sso], with a space, and the profile refers to it with sso_session = my-sso. The two names must match exactly.
Adding a second account
Run the wizard again and enter the same session name. When it finds an existing session, it reuses the start URL, region and scopes. You then pick a different account and role and give the new profile its own name, for example prod. Both profiles now share one sso-session, so one sign-in covers both.
Common mistakes
- Wrong start URL or SSO region. The browser step fails or shows no accounts. Rerun the wizard with the correct values, or edit the
[sso-session]block. - Missing scope. Without
sso:account:access, the CLI cannot list accounts or fetch role credentials. - No accounts listed. Your user has no permission set assigned. Ask the Identity Center administrator to assign one.
- Mismatched names. A typo between
sso_sessionin the profile and the[sso-session ...]header leaves the profile unable to find its session.
The wizard output is plain text, so you can edit the file by hand afterward. Changing the default region or adding another profile needs no new run.
Exercise
You ran aws configure sso once and created the profile dev. You now need a prod profile for another account, using the same Identity Center. What do you enter for the session name, and what do you gain by doing so?
Show answer
Enter the same session name you used before (for example my-sso). The wizard reuses the existing start URL, SSO region and scopes, and both profiles point to one sso-session block. A single aws sso login then covers both profiles.