This guide explains how to authenticate and access AWS resources via the AWS Command Line Interface (CLI) when using IAM Identity Center.
ℹ️ Information: AWS Command Line Interface (CLI) provides the ability to interact with AWS services through the command line. When using IAM Identity Center, you can securely authenticate and access AWS resources across multiple accounts.
When using AWS IAM Identity Center, you can authenticate to the AWS CLI using:
After authentication, IAM Identity Center maps your login credentials to the corresponding IAM role to execute AWS CLI commands with appropriate permissions.
ℹ️ Information: There are two main methods for obtaining and refreshing temporary credentials for IAM Identity Center users:
This method allows you to obtain temporary credentials for a specific IAM role associated with a permission set in an AWS account. The process:
⚠️ Warning: Temporary credentials have a limited lifespan (typically 1 hour). You need to repeat this process when credentials expire.
💡 Pro Tip: This method uses the Open ID Connect (OIDC) standard with Device Code Authorization, providing a more seamless and secure authentication experience.
The process:
aws configure sso
command🔒 Security Note: The automatic refresh method not only improves user experience but also enhances security by:
ℹ️ Information: From AWS CLI v2.9.0 and above, you can use the SSO configuration file (~/.aws/config
) to store multiple profiles for different AWS accounts and permission sets, allowing quick switching between different roles.