Sub topic 1
Why long-term access keys are a liability
Prerequisites
This chapter assumes you can use a terminal, have AWS CLI version 2 installed, and understand AWS accounts and IAM roles. You also need access to an IAM Identity Center instance with an assigned permission set.
Why long-term access keys are a liability
A long-term access key is an IAM user credential that remains valid until someone disables or deletes it. It is usually stored in ~/.aws/credentials, an environment variable, or a third-party tool.
Long-lived credentials increase risk:
- A leaked key can be used until it is revoked.
- Developers often copy keys into scripts, logs, or shared systems.
- Rotation requires finding every place where the key was stored.
- The key may grant more access than the current task needs.
Temporary credentials contain an access key, secret key, and session token. They expire automatically. IAM Identity Center lets the AWS CLI obtain these credentials after a browser sign-in, without storing a permanent IAM user key.
How IAM Identity Center issues access
IAM Identity Center is AWS’s workforce sign-in service. It connects a person to an AWS account and an IAM role. The role receives temporary credentials for a limited session.
Permission sets and account assignments
A permission set is a reusable definition of allowed AWS actions, such as read-only access. An account assignment connects a user or group to a permission set in a specific AWS account.
For example, the same user might receive ReadOnlyAccess in a development account and a different permission set in production. Identity Center creates or updates the corresponding IAM role in each account. The CLI then requests credentials for the selected account and role.
Configuring an `sso-session` and profiles
The AWS CLI stores this configuration in ~/.aws/config. An sso-session holds shared sign-in details. Named profiles select an account, role, and default region.
[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-2Several profiles can share one sso-session, even when they target different accounts.
Exercise
Why is an Identity Center profile safer than putting a permanent access key in ~/.aws/credentials?
Show answer
The profile obtains temporary role credentials after sign-in, and those credentials expire without requiring key rotation across stored files.