For help in understanding the layout of settings pages, or in interpreting theSupport by AWS SDKs and tools table that follows, seeUnderstanding the settings pages of this guide.
This authentication mechanism uses AWS IAM Identity Center to get single sign-on (SSO) access to AWS services for your code.
In the AWS SDK API documentation, the IAM Identity Center credential provider is called the SSO credential provider.
After you enable IAM Identity Center, you define a profile for its settings in your shared AWSconfig file. This profile is used to connect to the IAM Identity Center access portal. When a user successfully authenticates with IAM Identity Center, the portal returns short-term credentials for the IAM role associated with that user. To learn how the SDK gets temporary credentials from the configuration and uses them for AWS service requests, seeHow IAM Identity Center authentication is resolved for AWS SDKs and tools.
There are two ways to configure IAM Identity Center through theconfig file:
(Recommended) SSO token provider configuration – Extended session durations. Includes support for custom session durations.
Legacy non-refreshable configuration – Uses a fixed, eight-hour session.
In both configurations, you need to sign in again when your session expires.
The following two guides contain additional information about IAM Identity Center:
For a deep dive on how the SDKs and tools use and refresh credentials using this configuration, seeHow IAM Identity Center authentication is resolved for AWS SDKs and tools.
You must first enable IAM Identity Center. For details about enabling IAM Identity Center authentication, seeEnabling AWS IAM Identity Center in theAWS IAM Identity Center User Guide.
Alternatively, for complete prerequisitesand the necessary sharedconfig file configuration that is detailed on this page, see the guided instructions for setting upUsing IAM Identity Center to authenticate AWS SDK and tools.
When you use the SSO token provider configuration, your AWS SDK or tool automatically refreshes your session up to your extended session period. For more information on session duration and maximum duration, seeConfigure the session duration of the AWS access portal and IAM Identity Center integrated applications in theAWS IAM Identity Center User Guide.
Thesso-session section of theconfig file is used to group configuration variables for acquiring SSO access tokens, which can then be used to acquire AWS credentials. For more details on this section within aconfig file, seeFormat of the config file.
The following sharedconfig file example configures the SDK or tool using adev profile to request IAM Identity Center credentials.
[profiledev]sso_session =my-ssosso_account_id =111122223333sso_role_name =SampleRole[sso-sessionmy-sso]sso_region =us-east-1sso_start_url =https://my-sso-portal.awsapps.com/startsso_registration_scopes =sso:account:accessThe previous examples shows that you define ansso-session section and associate it to a profile. Typically,sso_account_id andsso_role_name must be set in theprofile section so that the SDK can request AWS credentials.sso_region,sso_start_url, andsso_registration_scopes must be set within thesso-session section.
sso_account_id andsso_role_name aren't required for all scenarios of SSO token configuration. If your application only uses AWS services that support bearer authentication, then traditional AWS credentials are not needed. Bearer authentication is an HTTP authentication scheme that uses security tokens called bearer tokens. In this scenario,sso_account_id andsso_role_name aren't required. See the individual AWS service guide to determine if the service supports bearer token authorization.
Registration scopes are configured as part of ansso-session. Scope is a mechanism in OAuth 2.0 to limit an application's access to a user's account. The previous example setssso_registration_scopes to provide necessary access for listing accounts and roles.
The following example shows how you can reuse the samesso-session configuration across multiple profiles.
[profiledev]sso_session =my-ssosso_account_id =111122223333sso_role_name =SampleRole[profile prod]sso_session =my-ssosso_account_id =111122223333sso_role_name =SampleRole2[sso-sessionmy-sso]sso_region =us-east-1sso_start_url =https://my-sso-portal.awsapps.com/startsso_registration_scopes =sso:account:accessThe authentication token is cached to disk under the~/.aws/sso/cache directory with a file name based on the session name.
Automated token refresh isn't supported using the legacy non-refreshable configuration. We recommend using theSSO token provider configuration instead.
To use the legacy non-refreshable configuration, you must specify the following settings within your profile:
sso_start_url
sso_region
sso_account_id
sso_role_name
You specify the user portal for a profile with thesso_start_url andsso_region settings. You specify permissions with thesso_account_id andsso_role_name settings.
The following example sets the four required values in theconfig file.
[profilemy-sso-profile]sso_start_url =https://my-sso-portal.awsapps.com/startsso_region =us-west-2sso_account_id =111122223333sso_role_name =SSOReadOnlyRoleThe authentication token is cached to disk under the~/.aws/sso/cache directory with a file name based on thesso_start_url.
Configure this functionality by using the following:
sso_start_url - shared AWSconfig file settingThe URL that points to your organization's IAM Identity Center issuer URL or access portal URL. For more information, seeUsing the AWS access portal in theAWS IAM Identity Center User Guide.
To find this value, open theIAM Identity Center console, view theDashboard, findAWS access portal URL.
Alternatively, starting with version2.22.0 of the AWS CLI, you can instead use the value forAWS Issuer URL.
sso_region - shared AWSconfig file settingThe AWS Region that contains your IAM Identity Center portal host; that is, the Region you selected before enabling IAM Identity Center. This is independent from your default AWS Region, and can be different.
For a complete list of the AWS Regions and their codes, seeRegional Endpoints in theAmazon Web Services General Reference. To find this value, open theIAM Identity Center console, view theDashboard, and findRegion.
sso_account_id - shared AWSconfig file settingThe numeric ID of the AWS account that was added through the AWS Organizations service to use for authentication.
To see the list of available accounts, go to theIAM Identity Center console and open theAWS accounts page. You can also see the list of available accounts using theListAccounts API method in theAWS IAM Identity Center Portal API Reference. For example, you can call the AWS CLI methodlist-accounts.
sso_role_name - shared AWSconfig file settingThe name of a permission set provisioned as an IAM role that defines the user's resulting permissions. The role must exist in the AWS account specified bysso_account_id. Use the role name, not the role Amazon Resource Name (ARN).
Permission sets have IAM policies and custom permissions policies attached to them and define the level of access that users have to their assigned AWS accounts.
To see the list of available permission sets per AWS account, go to theIAM Identity Center console and open theAWS accounts page. Choose the correct permission set name listed in the AWS accounts table. You can also see the list of available permission sets using theListAccountRoles API method in theAWS IAM Identity Center Portal API Reference. For example, you can call the AWS CLI methodlist-account-roles.
sso_registration_scopes - shared AWSconfig file settingA comma-delimited list of valid scope strings to be authorized for thesso-session. An application can request one or more scopes, and the access token issued to the application is limited to the scopes granted. A minimum scope ofsso:account:access must be granted to get a refresh token back from the IAM Identity Center service. For the list of available access scope options, seeAccess scopes in theAWS IAM Identity Center User Guide.
These scopes define the permissions requested to be authorized for the registered OIDC client and access tokens retrieved by the client. Scopes authorize access to IAM Identity Center bearer token authorized endpoints.
This setting doesn't apply to the legacy non-refreshable configuration. Tokens issued using the legacy configuration are limited to scopesso:account:access implicitly.
The following SDKs support the features and settings described in this topic. Any partial exceptions are noted. Any JVM system property settings are supported by the AWS SDK for Java and the AWS SDK for Kotlin only.
| SDK | Supported | Notes or more information |
|---|---|---|
| AWS CLI v2 | Yes | |
| SDK for C++ | Yes | |
| SDK for Go V2 (1.x) | Yes | |
| SDK for Go 1.x (V1) | Yes | To use sharedconfig file settings, you must turn on loading from the config file; seeSessions. |
| SDK for Java 2.x | Yes | Configuration values also supported incredentials file. |
| SDK for Java 1.x | No | |
| SDK for JavaScript 3.x | Yes | |
| SDK for JavaScript 2.x | Yes | |
| SDK for Kotlin | Yes | |
| SDK for .NET 4.x | Yes | |
| SDK for .NET 3.x | Yes | |
| SDK for PHP 3.x | Yes | |
| SDK for Python (Boto3) | Yes | |
| SDK for Ruby 3.x | Yes | |
| SDK for Rust | Partial | Legacy non-refreshable configuration only. |
| SDK for Swift | Yes | |
| Tools for PowerShell V5 | Yes | |
| Tools for PowerShell V4 | Yes |