Sub topic 2
How IAM Identity Center issues access
This chapter assumes you know what an AWS account and an IAM role are, and that you can use a terminal. It explains the working model behind aws sso login, so the commands in later chapters make sense. You do not need to configure anything yet.
The problem it solves
An IAM user with access keys gives you a credential that never expires on its own. IAM Identity Center replaces that with a sign-in step. You prove who you are once, and AWS hands out credentials that expire after a short time. Nothing long-lived has to be stored on your laptop.
The pieces
IAM Identity Center is the AWS service that manages workforce sign-in across many AWS accounts. Four terms matter here:
- Identity Center instance: the one directory and sign-in service for your organization. It has a start URL, such as
https://example.awsapps.com/start, and a home Region. - User: a person in the Identity Center directory, or one synced from an external identity provider.
- Permission set: a template of permissions that Identity Center turns into an IAM role in a target account. The next chapter covers it in detail.
- Account assignment: a link between a user (or group), a permission set, and an AWS account.
What happens when you sign in
Identity Center never gives the CLI your password. The CLI uses an OAuth-style device authorization flow. It asks Identity Center for a device code and then sends you to a browser, where you sign in and approve the request. After that, the CLI holds two kinds of temporary material.
- An access token proves that you signed in to Identity Center. It is not an AWS credential. You cannot use it to call Amazon S3 or any other service.
- Role credentials are the real AWS credentials: an access key ID, a secret access key, and a session token. The CLI requests them for one account and one role by presenting the access token.
The access token is the single sign-in. The role credentials are issued per account and role, and only when a command needs them.
Why the credentials are safer
Each role credential set is temporary, and Identity Center scopes it to the role you were assigned. If a credential leaks, it stops working on its own. Revoking a person's access also becomes one change in Identity Center, not a hunt for keys across accounts.
The IAM role behind the credentials lives in the target account. You can see this later in the output of aws sts get-caller-identity, where the ARN names an assumed role.
Where the pieces appear in your config
The start URL and home Region you saw above go into an sso-session block. The account and role go into a profile. Here is a preview of how they line up. Chapter 4 explains each line.
[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 sso_region is the Region where Identity Center lives. The region in the profile is the Region your commands target. They are often different, and mixing them up is a common cause of errors.
Exercise
After you sign in through the browser, why can you not use the Identity Center access token to call Amazon S3 directly?
Show answer
The access token only proves you signed in to Identity Center. To call AWS services, the CLI must exchange it for temporary role credentials (access key ID, secret access key, and session token) for a specific account and role.
Exercise
A profile has sso_region = us-east-1 and region = us-west-2. Which Region is used for the sign-in service, and which for your commands?
Show answer
us-east-1 is where Identity Center runs, so the CLI uses it for sign-in and for requesting credentials. Commands such as aws s3 ls target us-west-2.