AWS SSO / IAM Identity Center CLI Login
IAM Identity Center (formerly AWS SSO) gives you short-lived, auto-refreshing credentials instead of long-lived access keys. You log in once with aws sso login, and both SDKs use the result.
Busca en todas las páginas de la documentación
IAM Identity Center (formerly AWS SSO) gives you short-lived, auto-refreshing credentials instead of long-lived access keys. You log in once with aws sso login, and both SDKs use the result.
IAM Identity Center is AWS's single sign-on service for workforce access across accounts. It replaces static keys with browser-based login.
You configure it once with aws configure sso, which writes an sso-session and a profile into ~/.aws/config. No secret key is ever stored on disk.
Running aws sso login opens a browser, you approve the device, and the CLI caches a short-lived SSO token. From that token it fetches temporary role credentials.
boto3 and the AWS SDK for JavaScript v3 read the same SSO profile from the shared config. When their credentials expire, they refresh from the cached SSO token automatically.
This is the recommended setup for any team or organization. Long-lived keys should be a last resort.
Configure once, then log in whenever your session expires.
# One-time interactive setup - writes ~/.aws/config
aws configure sso
# SSO start URL: https://my-org.awsapps.com/start
# SSO region: us-east-1
# then pick an account + role, and name the profile (e.g. "dev-sso")
# Log in (opens a browser); refresh this when the session expires
aws sso login --profile dev-sso
# Verify
aws sts get-caller-identity --profile dev-ssoWhen to reach for this:
After aws sso login, both SDKs use the SSO profile with no keys in code.
The profile it wrote looks like this:
# ~/.aws/config
[sso-session my-org]
sso_start_url = https://my-org.awsapps.com/start
sso_region = us-east-1
sso_registration_scopes = sso:account:access
[profile dev-sso]
sso_session = my-org
sso_account_id = 111111111111
sso_role_name = DeveloperAccess
region = us-east-1
output = jsonNow the SDK code:
# --- Python (boto3) ---
import boto3
# Uses the SSO profile; boto3 reads the cached SSO token and
# fetches short-lived role credentials automatically.
session = boto3.Session(profile_name="dev-sso")
sts = session.client("sts")
identity = sts.get_caller_identity()
print("SSO identity:", identity["Arn"])// --- TypeScript (AWS SDK v3) ---
import { fromSSO } from "@aws-sdk/credential-providers";
import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";
// Uses the SSO profile; v3 reads the cached SSO token and
// fetches short-lived role credentials automatically.
const sts = new STSClient({
region: "us-east-1",
credentials: fromSSO({ profile: "dev-sso" }),
});
const identity = await sts.send(new GetCallerIdentityCommand({}));
console.log("SSO identity:", identity.Arn);What this demonstrates:
fromSSO provider from @aws-sdk/credential-providers to resolve the same profile.aws sso login.aws configure sso records where to log in (the sso-session) and which account/role a profile maps to.aws sso login performs the OAuth device-authorization flow in a browser and caches an SSO token under ~/.aws/sso/cache/.sso:GetRoleCredentials API.aws sso login.Modern setup uses a shared [sso-session ...] block that multiple profiles reference.
sso-session centralizes the start URL and SSO region so many account/role profiles reuse one login.sso_start_url and sso_region directly in each profile block; those still work but are being phased out.sso-session form - one login covers every profile that points at it.| Command | Purpose |
|---|---|
aws configure sso | Interactive first-time setup |
aws configure sso-session | Create or edit just the sso-session block |
aws sso login --profile <p> | Start or refresh a login |
aws sso logout | Clear the cached SSO token |
aws sso login --profile <p> again; the token has a limited lifetime.fromSSO (or set the profile via AWS_PROFILE) may not resolve an SSO profile. Fix: use fromSSO({ profile }) or set AWS_PROFILE and let the default chain resolve it.sso-session format require AWS CLI v2. Fix: upgrade to v2; v1 is end-of-support.fromSSO supplies credentials, not the client region. Fix: set region on the client or AWS_REGION.sso_account_id or sso_role_name typos yield authorization failures even after a successful login. Fix: re-run aws configure sso and pick from the presented list.| Alternative | Use When | Don't Use When |
|---|---|---|
| IAM Identity Center (SSO) | Team/org access, want short-lived logins | You have no Identity Center set up |
| Long-lived access keys | Quick solo experiment, no org | Shared machines or production - too risky |
Assumed roles via role_arn | One base identity reaching many accounts | You want centralized login without base keys |
| Instance/container roles | Code running inside AWS | Local development on your laptop |
Yes. AWS renamed AWS Single Sign-On to IAM Identity Center. The CLI commands (aws sso login, aws configure sso) kept the sso name.
No. It caches a short-lived SSO token under ~/.aws/sso/cache/. Role credentials are fetched from that token and are also temporary.
They read the SSO profile from ~/.aws/config. boto3 resolves it through the default chain; v3 uses the fromSSO provider or the profile via AWS_PROFILE.
Your SSO session likely expired. Run aws sso login --profile <p> again to refresh it.
A shared block in ~/.aws/config that holds the start URL and SSO region. Multiple profiles reference it so one login covers many account/role profiles.
Yes. SSO login and the sso-session format require AWS CLI v2. Version 1 does not fully support them and is end-of-support.
Re-run aws configure sso for that profile and choose a different account and role from the list, or edit sso_account_id and sso_role_name in the config.
Yes, as long as the cached SSO token is still valid, fromSSO fetches fresh role credentials when the current ones expire.
aws sso logoutIt clears the cached SSO token so no tool can fetch new credentials until you log in again.
Not well - CI has no browser for the interactive login. Use OIDC-based role assumption or injected temporary credentials in CI instead.
fromSSO returns credentials only. Set region on the client or AWS_REGION.
Under ~/.aws/sso/cache/ as JSON files. Deleting them forces a fresh aws sso login.
Stack versions: This page was written for the AWS CLI v2, boto3 1.43.x (Python 3.10+), and the AWS SDK for JavaScript v3 (Node.js 18+).
Revisado por Chris St. John·Última actualización: 24 jul 2026