AWS - SDKs and Tools Reference Guide
AWS - SDKs and Tools Reference Guide
Reference Guide
AWS SDKs and Tools Reference Guide
Amazon's trademarks and trade dress may not be used in connection with any product or service that is not
Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or
discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may
or may not be affiliated with, connected to, or sponsored by Amazon.
AWS SDKs and Tools Reference Guide
Table of Contents
AWS SDKs and Tools Reference Guide .................................................................................................. 1
Applicable to all SDKs and tools .................................................................................................. 1
Applicable to some SDKs and tools .............................................................................................. 1
Configuration ..................................................................................................................................... 2
Additional topics in this section ................................................................................................... 2
Shared config and credentials files ........................................................................................ 2
Profiles ............................................................................................................................. 3
Format of the config file ..................................................................................................... 3
Format of the credentials file .............................................................................................. 4
Example files ..................................................................................................................... 4
Location of the shared files ......................................................................................................... 5
Supported SDKs and tools .......................................................................................................... 6
Environment variables ................................................................................................................ 7
How to set environment variables ........................................................................................ 7
Credentials and access ........................................................................................................................ 9
Topics in this section .................................................................................................................. 9
Accounts, users, and roles ........................................................................................................... 9
Create an account .............................................................................................................. 9
Create an administrative user ............................................................................................ 10
Create an IAM user for development .................................................................................. 10
Create an IAM role ........................................................................................................... 11
SSO ........................................................................................................................................ 12
MFA ........................................................................................................................................ 12
Step 1: Creating an IAM role to delegate access to IAM users ................................................ 12
Step 2: Creating an IAM user that assumes the role's permissions ........................................... 13
Step 3: Managing a virtual MFA device for the IAM user ........................................................ 14
Step 4: Creating profiles to allow MFA ................................................................................ 14
IAM roles for Amazon EC2 instances ........................................................................................... 15
Create an IAM role ........................................................................................................... 15
Launch an Amazon EC2 instance and specify your IAM role .................................................... 15
Connect to the EC2 instance .............................................................................................. 16
Run the sample application on the EC2 instance .................................................................. 16
IAM role from an IAM user ........................................................................................................ 16
Scenario description ......................................................................................................... 16
How to configure the profile ............................................................................................. 17
How to use the profile ...................................................................................................... 18
Config and auth settings reference ..................................................................................................... 19
Creating service clients ............................................................................................................. 19
Precedence of settings .............................................................................................................. 19
Config file settings list ............................................................................................................ 20
Credentials file settings list ................................................................................................... 21
Environment variables list ......................................................................................................... 21
Standardized credential providers ............................................................................................... 22
Credential provider chain .................................................................................................. 23
Assume role credentials .................................................................................................... 23
Container credentials ........................................................................................................ 27
IMDS credentials .............................................................................................................. 28
Process credentials ........................................................................................................... 30
SSO credentials ................................................................................................................ 32
Static credentials .............................................................................................................. 34
Standardized features ............................................................................................................... 36
Amazon EC2 instance metadata ......................................................................................... 36
Amazon S3 access points .................................................................................................. 37
Amazon S3 Multi-Region Access Points ............................................................................... 38
iii
AWS SDKs and Tools Reference Guide
iv
AWS SDKs and Tools Reference Guide
Applicable to all SDKs and tools
This AWS SDKs and Tools Reference Guide is intended to be a base of information that is applicable to
multiple SDKs and tools. The specific SDK or tool guide for the SDK or tool you are using should be used
in addition to any information presented here. The following SDKs and tools have additional information
represented in this guide:
• Configuration (p. 2) – How to use the shared config and credentials files or environment
variables for the authentication and configuration of an AWS SDK or tool.
• Configuration and authentication settings reference (p. 19) – Reference for all standardized settings
available for authentication and configuration.
• AWS Common Runtime (CRT) libraries (p. 53) – Overview of the AWS Common Runtime (CRT)
libraries that are available to almost all SDKs.
1
AWS SDKs and Tools Reference Guide
Additional topics in this section
Configuration
With AWS SDKs and other AWS developer tools, such as the AWS Command Line Interface (AWS CLI), you
can interact with AWS service APIs. Before attempting that, however, you must configure the SDK or tool
with the information that it needs to perform the requested operation.
• Credentials information that identifies who is calling the API. The credentials are used to encrypt
the request to the AWS servers. Using this information, AWS confirms your identity and can retrieve
permissions policies associated with it. Then it can determine what actions you're allowed to perform.
• Other configuration details that you use to tell the AWS CLI or SDK how to process the request, where
to send the request (to which AWS service endpoint), and how to interpret or display the response.
Each SDK or tool supports multiple sources that you can use to supply the required credential and
configuration information. Some sources are unique to the SDK or tool, and you must refer to the
documentation for that tool or SDK for the details on how to use that method.
However, most of the AWS SDKs and tools support common settings from two primary sources (beyond
the code itself):
• Shared AWS config and credentials files (p. 2) – The shared config and credentials files are
the most common way that you can specify authentication and configuration to an AWS SDK or tool.
Use these files to store settings that your tools and applications can use. Settings within the shared
config and credentials files are associated with a specific profile. With multiple profiles, you can
create different settings configurations to apply in different scenarios. When you use an AWS tool to
invoke a command or use an SDK to invoke an AWS API, you can specify which profile, and thus which
configuration settings, to use for that action. One of the profiles is designated as the default profile
and is used automatically when you don't explicitly specify a profile to use. The settings that you can
store in these files are documented in this reference guide.
• Environment variables (p. 7) – Some of the settings can alternatively be stored in the
environment variables of your operating system. Although you can have only one set of environment
variables in effect at a time, they are easily modified dynamically as your program runs and your
requirements change.
2
AWS SDKs and Tools Reference Guide
Profiles
values are attached to a profile in order to configure some aspect of the SDK/tool when that profile is
used.
As a general rule, any value that you can place in the shared credentials file can alternatively
be placed in the shared config file. The reverse isn't true; only a few settings can be placed in the
credentials file. However, as a security best practice, we recommend that you keep any sensitive
values, such as access key IDs and secret keys, in the separate credentials file. This way, you can
provide separate permissions for each file, if necessary.
We recommend downloading these files from the AWS Management Console by following the
instructions for Managing access keys in the IAM User Guide.
Both the shared config and credentials files are plaintext files that contain only ASCII characters
(UTF-8 encoded). They take the form of what are generally referred to as INI files.
Profiles
Settings within the shared config and credentials files are associated with a specific profile. With
multiple profiles, you can create different settings configurations to apply in different scenarios.
The [default] profile contains the values that are used by an SDK or tool operation if a specific named
profile is not specified. You can also create separate profiles that you can explicitly reference by name.
Each named profile can have a different group of settings.
[default] is simply an unnamed profile. This profile is named default because it is the default profile
used by the SDK if the user does not specify a profile. It does not provide inherited default values to
other profiles. For example, if you set something in the [default] profile and you don't set it in a
named profile, then the value isn't set when you use the named profile.
Optionally, set a named profile that you want to use through your SDK code or AWS CLI commands.
Alternatively, you can use the environment variable AWS_PROFILE to specify which profile's settings to
use.
export AWS_PROFILE="my_named_profile";
The following example shows a basic config file having a [default] profile. It sets the
region (p. 40) global setting.
[default]
#Full line comment, this text is ignored.
region = us-east-2
3
AWS SDKs and Tools Reference Guide
Format of the credentials file
To create a named profile in the config file, create a section with a new header, similar to the following
example. You must use the word profile and follow it with a unique name. You can use letters,
numbers, hyphens ( - ), and underscores ( _ ), but no spaces.
[profile developers]
...settings...
Some settings have their own nested group of subsettings, such as the s3 setting and subsettings in the
following example. Associate the subsettings with the group by indenting them by one or more spaces.
[profile testers]
region = us-west-2
s3 =
max_concurrent_requests=10
max_queue_size=1000
[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
The rules for the credentials file are generally identical to those for the config file, with the
following exceptions:
• The section names don't begin with the word profile. Use only the profile name itself between
square brackets.
[developers]
...settings...
• You can store only a subset of settings and values in the credentials file. Generally, it's only those
with values that would be considered "secrets" or sensitive, such as access key IDs and secret keys. The
page for each setting in this guide states whether it can be stored in the credentials file or only in
the config file.
Example files
In summary, each profile can have some settings in each file. The majority of settings go in the config
file, while the sensitive information settings go in the credentials file.
The following example shows three profiles stored in these two files:
• default profile – Provides access by using the long-term credentials of an AWS Identity and Access
Management (IAM) user. Tools or code that use this profile send requests to the US West (Oregon)
Region (us-west-2). AWS CLI commands invoked using this profile output the results as JSON.
• dev-user profile – Uses the long-term credentials of a different IAM user. Tools or code that use this
profile send requests to the US West (N. California) Region (us-west-1). AWS CLI commands invoked
using this profile output the results as text.
• developers profile – Uses short-term credentials from assuming the specified role. It uses the long-
term credentials in the dev-user source profile only to assume the role and retrieve the short-term
4
AWS SDKs and Tools Reference Guide
Location of the shared files
credentials for the role. Tools or code that use this profile send requests to the US West (Oregon)
Region (us-west-2). AWS CLI commands invoked using this profile output the results as JSON. This
profile doesn't store any of its values in the credentials file.
[default]
region = us-west-2
output = json
[profile dev-user]
region = us-west-1
output = text
[profile developers]
role_arn = arn:aws:iam::123456789012:role/developers
source_profile = dev-user
region = us-west-2
output = json
[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
[dev-user]
aws_access_key_id = AKIAI44QH8DHBEXAMPLE
aws_secret_access_key = je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
~/.aws/credentials
Windows %USERPROFILE%\.aws\config
%USERPROFILE%\.aws\credentials
A ~/ or ~ followed by the file system's default path separator at the start of the path is resolved by
checking, in order,
5
AWS SDKs and Tools Reference Guide
Supported SDKs and tools
When possible, if a user's home directory is specified at the start of the path (for example, ~username/),
it is resolved to the requested user name's home directory (for example, /home/username/.aws/
config).
The following environment variables can be set to change the location or name of these files from the
default to a custom value:
Linux/macOS
You can specify an alternate location by running the following export commands on Linux or macOS.
$ export AWS_CONFIG_FILE=/some/file/path/on/the/system/config-file-name
$ export AWS_SHARED_CREDENTIALS_FILE=/some/other/file/path/on/the/system/credentials-
file-name
Windows
You can specify an alternate location by running the following setx commands on Windows.
Each entry includes a link to that SDK's or tool's documentation where the use of these files is discussed
in detail.
AWS Cloud Development Kit (AWS CDK) Getting started with AWS Cloud Development Kit
(AWS CDK)
AWS Command Line Interface (AWS CLI) Configuring the AWS CLI
6
AWS SDKs and Tools Reference Guide
Environment variables
AWS SDK for PHP Using the AWS Credentials File and Credential
Profiles
AWS Toolkit for JetBrains Setting AWS Credentials for the AWS Toolkit for
JetBrains
AWS Toolkit for Visual Studio Code Setting Up Your AWS Credentials
AWS Tools for PowerShell Getting Started with AWS Tools for PowerShell
Precedence of options
• If you specify a setting by using its environment variable, it overrides any value loaded from a profile in
the shared AWS config and credentials files.
• If you specify a setting by using a parameter on the AWS CLI command line, it overrides any value from
either the corresponding environment variable or a profile in the configuration file.
$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
$ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
$ export AWS_DEFAULT_REGION=us-west-2
Setting the environment variable changes the value used until the end of your shell session, or until
you set the variable to a different value. You can make the variables persistent across future sessions
by setting them in your shell's startup script.
Windows Command Prompt
7
AWS SDKs and Tools Reference Guide
How to set environment variables
Using set to set an environment variable changes the value used until the end of the current
Command Prompt session, or until you set the variable to a different value. Using setx to set an
environment variable changes the value used in both the current Command Prompt session and
all Command Prompt sessions that you create after running the command. It does not affect other
command shells that are already running at the time you run the command.
PowerShell
PS C:\> $Env:AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
PS C:\> $Env:AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
PS C:\> $Env:AWS_DEFAULT_REGION="us-west-2"
If you set an environment variable at the PowerShell prompt as shown in the previous examples,
it saves the value for only the duration of the current session. To make the environment variable
setting persistent across all PowerShell and Command Prompt sessions, store it by using the System
application in Control Panel. Alternatively, you can set the variable for all future PowerShell sessions
by adding it to your PowerShell profile. See the PowerShell documentation for more information
about storing environment variables or persisting them across sessions.
8
AWS SDKs and Tools Reference Guide
Topics in this section
• AWS account root user credentials and IAM user credentials – Root user credentials vs IAM credentials,
tasks that require root user credentials
• Understanding and getting your AWS credentials – Access key options and management practices for
both console and programmatic access
• Your AWS account identifiers – Finding and understanding your AWS account ID
The IAM User Guide is always the best resource for securely controlling access to AWS resources:
• Security best practices in IAM – Security recommendations to follow when developing AWS
applications in keeping with our shared-responsibility model
Roles allow you to gain access to AWS using your existing identities. You can federate in from an external
identity provider, like Active Directory or Okta, or you can assume a role from a different user or role
within AWS. You can use roles to build your applications securely by assuming different roles for different
job functions, and keeping roles with access to sensitive data separated from your other identities.
Users are meant for when you have no other identity to connect to AWS with. If you need an entry point
to AWS but you don’t have a separate identity provider, you can create a user to sign into AWS with so
that you don’t have to use the AWS account root user. Users have long-lived credentials that you should
rotate regularly. If you need to use a user in AWS, we recommend using the user only to sign in to AWS
and then to assume a role that can perform your job function.
Although users are a good way to get started using AWS services, we recommend all developers consider
setting up single sign-on for access. For more information, see Single sign-on (SSO) (p. 12).
Create an account
To create an AWS account, see How do I create and activate a new Amazon Web Services account?
9
AWS SDKs and Tools Reference Guide
Create an administrative user
After you create the administrative user account and record the login details, sign out as root user and
sign back in using the administrative account.
The administrative user account still grants full access to most things - it is not appropriate for doing
SDK development on AWS or for running applications on AWS. Thus, you need to create user accounts
and service roles that are appropriate for these tasks. The specific user accounts and service roles that
you create, and the way in which you use them, depend on the requirements of your applications.
To programmatically interface with AWS, one option is to create an IAM user and obtain credentials for
that user. Then make them available to the SDK/tool in your development environment by saving them
to the shared AWS credentials file.
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. Choose Users, and then choose Add users.
3. Provide a user name.
4. Under Select AWS access type, select Programmatic access, and then choose Next: Permissions.
5. Choose Attach existing policies directly, and then select the appropriate policies for the AWS
services that your application will use.
For example, if you wanted your application to have full access to the Amazon S3 service: In Search,
enter s3, and then select AmazonS3FullAccess as the policy to attach to this user. For best practices
regarding policies, see Grant least privilege in the IAM User Guide.
Warning
The AdministratorAccess policy enables read and write permissions to almost everything in
your account. We recommend choosing a more restrictive policy for development.
6. Choose Next: Tags and enter any tags you want.
You can find information about tags in Control access using AWS resource tags in the IAM User
Guide.
7. Choose Next: Review, and then choose Create user.
8. On the Success screen, choose Download .csv.
The downloaded file contains the Access Key ID and the Secret Access Key for this IAM user.
Note
You will not have another opportunity to download or copy the Secret Access Key.
Treat your Secret Access Key as a password; save in a trusted location and do not share it.
Warning
Use appropriate security measures to keep these credentials safe and rotated. See Security
best practices in IAM in the IAM User Guide.
10
AWS SDKs and Tools Reference Guide
Create an IAM role
You now have the credentials for this user. For an AWS SDK or tool to be able to use these
credentials, they can be put into the shared AWS credentials file.
9. Create or open the shared credentials file. This file is ~/.aws/credentials on Linux and
macOS systems, and %USERPROFILE%\.aws\credentials on Windows. See Location of
Credentials Files for more information.
10. Add the following text to the shared credentials file, but replace the example ID value and
example key value with the ones you obtained earlier.
[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Comprehensive coverage of navigating all the options in the Add users console wizard is at Creating IAM
users (console) in the IAM User Guide
Note that there are other ways of storing credentials (such as the SDK Store available to the AWS SDK
for .NET), but the shared credentials file is the most common.
The process for creating a service role varies depending on the situation, but is essentially the following.
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. Choose Roles, and then choose Create role.
3. Choose AWS service.
4. Under Choose a use case, select the service you want to allow to call services on your behalf.
For example, if you were working with the Amazon EC2 service, then select EC2 as your use case.
5. Choose Next: Permissions, and select the appropriate policies for the AWS services that your
application will use.
For example, if you wanted your application to have full access to the Amazon EC2 service: In
Search, enter ec2, and then select AmazonEC2FullAccess as the policy to attach. For best practices
regarding policies, see Grant least privilege in the IAM User Guide.
Warning
The AdministratorAccess policy enables read and write permissions to almost everything in
your account. We recommend choosing a more restrictive policy for development.
6. Choose Next: Tags and enter any tags you want.
You can find information about tags in Control access using AWS resource tags in the IAM User
Guide.
7. Choose Next: Review and provide a Role name and Role description. Then choose Create role.
Comprehensive coverage of navigating all the options in the Create role console wizard is at Creating a
role for an AWS service (console) in the IAM User Guide
11
AWS SDKs and Tools Reference Guide
SSO
To use SSO credentials with your AWS SDK, you'll do the following:
• Enable IAM Identity Center – This includes choosing your identity source and setting up IAM Identity
Center access to your AWS accounts. For steps on this setup, see Getting started in the AWS IAM
Identity Center (successor to AWS Single Sign-On) User Guide.
• Configure AWS IAM Identity Center (successor to AWS Single Sign-On) for your application – Define
a named profile in the shared AWS config file that is used to retrieve temporary credentials for your
AWS account. For details on the required settings, see SSO credentials (p. 32).
• Get an SSO Token – To use an SSO-enabled profile, you must generate a temporary token. This can be
done either programmatically or by running the aws sso login command from the AWS CLI.
In the AWS CLI, for example, to sign in with a named profile instead of the default profile, pass the
profile name using the --profile parameter:
To learn how to get and renew tokens programmatically, see your specific AWS SDK developer guide.
AWS supports a range of both virtual and hardware devices for MFA authentication. The example
that's documented here is a virtual MFA device that's enabled by a smartphone application. For more
information on MFA device options, see Using multi-factor authentication (MFA) in AWS in the IAM User
Guide.
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. Choose Roles in the navigation bar, and then choose Create Role.
3. In the Create role page, choose Another AWS account.
4. Enter your required Account ID and mark the Require MFA check box.
Note
To find your 12-digit account number (ID), go to the navigation bar in the console, and then
choose Support, Support Center.
12
AWS SDKs and Tools Reference Guide
Step 2: Creating an IAM user that
assumes the role's permissions
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. Choose Users in the navigation bar and then choose Add user.
3. In the Add user page, enter a required User name (my-user, for example) and mark the
Programmatic access check box.
4. Choose Next: Permissions, Next: Tags, and Next: Review to move through the next pages. You're
not adding permissions at this stage because the user is going to assume the role's permissions.
5. In the Review page, you're informed that This user has no permissions. Choose Create user.
6. In the Success page, choose Download .csv to download the file containing the access key ID and
secret access key. (You need both when defining the user's profile in the shared AWS credentials
file.)
7. Choose Close.
1. In the Users page of the IAM console, choose the IAM user you've just created (my-user, for
example).
2. In the Permissions tab of the Summary page, choose Add inline policy.
3. In the Create policy page, choose Choose a service, enter STS in Find a service, and then choose
STS from the results.
4. For Actions, start entering the term AssumeRole. Mark the AssumeRole check box when it appears.
5. In the Resource section, ensure Specific is selected, and click Add ARN to restrict access.
6. In the Add ARN(s) dialog box, for the Specify ARN for role add the ARN of the role you that you
created in Step 1.
After you add the role's ARN, the trusted account and role name associated with that role are
displayed in Account and Role name with path.
13
AWS SDKs and Tools Reference Guide
Step 3: Managing a virtual MFA device for the IAM user
7. Choose Add.
8. Back in the Create policy page, choose Specify request conditions (optional), mark the MFA
required check box, and then choose close to confirm..
9. Choose Review policy
10. In Review policy page, enter a Name for the policy, and then choose Create policy.
The Permissions tab displays the new inline policy attached directly to IAM user.
For a list of supported applications, see the Multi-factor Authentication resource page.
2. In the IAM console, choose Users from the navigation bar and then choose the user that's assuming
a role (my-user, in this case).
3. In the Summary page, choose the Security credentials tab, and for Assigned MFA device choose
Manage.
4. In the Manage MFA device pane, choose Virtual MFA device, and then choose Continue.
5. In the Set up virtual MFA device pane, choose Show QR code and then scan the code using the
virtual MFA application that you installed on your smartphone.
6. After you scan the QR code, the virtual MFA application generates one-time MFA codes. Enter two
consecutive MFA codes in MFA code 1 and MFA code 2.
7. Choose Assign MFA.
8. Back in the Security credentials tab for the user, copy the ARN of the new Assigned MFA device.
The ARN includes your 12-digit account ID and the format is similar to the following:
arn:aws:iam::123456789012:mfa/my-user. You need this ARN when defining the MFA profile
in the next step.
The profiles that you create include three pieces of information that you've copied and stored during the
previous steps:
• Access keys (access key ID and secret access key) for the IAM user
• ARN of the role that's delegating permissions to the IAM user
• ARN of the virtual MFA device that's assigned to the IAM user
In the shared AWS config and credentials files or SDK Store that contain your AWS credentials, add
the following entries:
[my-user]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
[mfa]
source_profile = my-user
14
AWS SDKs and Tools Reference Guide
IAM roles for Amazon EC2 instances
role_arn = arn:aws:iam::111111111111:role/my-role
mfa_serial = arn:aws:iam::111111111111:mfa/my-user
• [my-user] profile includes the access key and secret access key that were generated and saved when
you created the IAM user in Step 2.
• Details on using these two settings can be found at Static credentials (p. 34).
• [mfa] profile defines how multi-factor authentication is supported. There are three entries:
• source_profile: Specifies the profile whose credentials are used to assume the role specified by
this role_arn setting in this profile. In this case, it's the my-user profile.
• role_arn: Specifies the Amazon Resource Name (ARN) of the IAM role that you want to use to
perform operations requested using this profile. In this case, it's the ARN for the role you created in
Step 1.
• mfa_serial: Specifies the identification or serial number of the MFA device that the user must use
when assuming a role. In this case, it's the ARN of the virtual device you set up in Step 3.
• Details on using these three settings can be found at Assume role credentials (p. 23).
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the navigation pane, choose Roles, then Create New Role.
3. On the Select Role Type page, under AWS-service Roles, choose Amazon EC2.
4. On the Attach Policy page, choose Amazon S3 Read Only Access from the policy list, then choose
Next Step. Enter a name for the role, then select Next Step. Remember this name because you'll need
it when you launch your Amazon EC2 instance.
5. On the Review page, choose Create Role.
Follow the directions to launch an instance in the Amazon EC2 User Guide for Linux Instances or the
Amazon EC2 User Guide for Windows Instances.
When you reach the Review Instance Launch page, select Edit instance details. In IAM role, choose the
IAM role that you created previously. Complete the procedure as directed.
Note
You need to create or use an existing security group and key pair to connect to the instance.
15
AWS SDKs and Tools Reference Guide
Connect to the EC2 instance
With this IAM and Amazon EC2 setup, you can deploy your application to the Amazon EC2 instance and it
will have read access to the Amazon S3 service.
You can do this by following the connect procedure in the Amazon EC2 User Guide for Linux Instances or
the Amazon EC2 User Guide for Windows Instances. When you connect, do so in such a way that you can
transfer files from your development machine to your instance.
If you're using an AWS Toolkit, you can often also connect to the instance by using the Toolkit. For more
information, see the specific user guide for the Toolkit you use.
For information about how to transfer files to your instance see the Amazon EC2 User Guide for
Linux Instances or the Amazon EC2 User Guide for Windows Instances.
2. Start the application and verify that it runs with the same results as on your development machine.
3. (Optional) Verify that the application uses the credentials provided by the IAM role.
a. Sign in to the AWS Management Console and open the Amazon EC2 console at https://
console.aws.amazon.com/ec2/.
b. Select the instance and detach the IAM role through Actions, Instance Settings, Attach/
Replace IAM Role.
c. Run the application again and confirm that it returns an authorization error.
Scenario description
This scenario requires that you have two entities created in IAM:
• An IAM user, that in this example we call UserAlpha. This user has IAM policy permissions that enable
it to perform only the sts:AssumeRole operation. The following JSON policy document describes
this user in IAM policy language. To better understand the components of IAM policy language, see
IAM JSON policy elements reference in the IAM User Guide. However, when getting started, it is far
more common to simply use the AWS Management Console to graphically create users, roles, etc.
rather than writing them manually.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
16
AWS SDKs and Tools Reference Guide
How to configure the profile
"Action": "sts:AssumeRole",
"Resource": "*"
}
]
}
• An IAM role, that in this example we call RoleBeta. This role has a trust policy that enables all users in
the account to assume the role.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::231179739868:root"
},
"Action": "sts:AssumeRole",
"Condition": {}
}
]
}
It also has IAM permission policies that enable it to perform any task in Amazon S3. When getting
started, it is far more common to simply use the AWS Management Console and assign AWS managed
policies.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}
[profile UserAlpha]
region = us-west-2
output = json
[profile RoleBeta]
source_profile = UserAlpha
role_arn = arn:aws:iam::123456789012:role/RoleBeta
[UserAlpha]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
17
AWS SDKs and Tools Reference Guide
How to use the profile
18
AWS SDKs and Tools Reference Guide
Creating service clients
SDKs provide language-specific APIs for AWS services. They take care of some of the heavy lifting
necessary in successfully making API calls, including authentication, retry behavior, and more. To do this,
the SDKs have flexible strategies to obtain credentials to use for your requests, to maintain settings to
use with each service, and to obtain values to use for global settings.
Precedence of settings
Global settings configure features, credential providers, and other functionality that are supported
by most SDKs and have a broad impact across AWS services. All SDKs have a series of places (or
sources) that they check in order to find a value for global settings. The following is the setting lookup
precedence:
1. Any explicit setting set in the code or on a service client itself takes precedence over anything else.
• Some settings can be set on a per-operation basis, and can be changed as needed for each
operation that you invoke. For the AWS CLI or AWS Tools for PowerShell, these take the form of
per-operation parameters that you enter on the command line. For an SDK, explicit assignments
can take the form of a parameter that you set when you instantiate an AWS service client or
configuration object, or sometimes when you call an individual API.
2. Java/Kotlin only: Sometimes there is a JVM system property associated with the setting. If it’s set, that
value is used to configure the client.
3. The environment variable is checked. If it’s set, that value is used to configure the client.
4. The SDK checks the shared credentials file and then the shared config file. If the setting is
present, the SDK uses it. The AWS_PROFILE environment variable or the aws.profile system
property can be used to specify which profile that the SDK loads.
5. Any default value provided by the SDK code base is used last.
Note
If a setting exists in both the config file and the credentials file for the same profile, the
value in the credentials file is used instead of the value in the config file.
19
AWS SDKs and Tools Reference Guide
Config file settings list
Note
Some SDKs and tools might check in a different order. Also, some SDKs and tools support other
methods of storing and retrieving parameters. For example, the AWS SDK for .NET supports an
additional source called the SDK Store. For more information about providers that are unique to
a SDK or tool, see the documentation for that SDK or tool (p. 6).
The order determines which methods take precedence and override others. For example, if you set up
a default profile in the shared config file, it's only found and used after the SDK or tool checks the
other places first. This means that if you put a setting in the credentials file, it is used instead of one
found in the config file. If you configure an environment variable with a setting and value, it would
override that setting in both the credentials and config files. And finally, a setting on the individual
operation (AWS CLI command-line parameter or API parameter) or in code would override all other
values for that one command.
20
AWS SDKs and Tools Reference Guide
Credentials file settings list
21
AWS SDKs and Tools Reference Guide
Standardized credential providers
Topics
• Credential provider chain (p. 23)
• Assume role credentials (p. 23)
• Container credentials (p. 27)
• IMDS credentials (p. 28)
• Process credentials (p. 30)
• SSO credentials (p. 32)
• Static credentials (p. 34)
22
AWS SDKs and Tools Reference Guide
Credential provider chain
For each step in the chain, there are a variety of ways to assign setting values. Setting values specified in
code always take precedence, but there are also Environment variables (p. 7) and the Shared AWSconfig
and credentials files (p. 2). For more information, see Precedence of settings (p. 19).
To learn more about IAM roles, see Using IAM roles in the IAM User Guide.
To learn more about assuming a role, see AssumeRole in the AWS Security Token Service API Reference.
Used within Amazon EC2 instances or containers to specify where the SDK or development tool
can find credentials that have permission to assume the role that you specify with the role_arn
parameter.
Valid values:
• Environment – Specifies that the SDK or tool is to retrieve source credentials from the
environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (p. 34).
• Ec2InstanceMetadata – Specifies that the SDK or tool is to use the IAM role attached to the EC2
instance profile to get source credentials.
• EcsContainer – Specifies that the SDK or tool is to use the IAM role attached to the ECS container
to get source credentials.
23
AWS SDKs and Tools Reference Guide
Assume role credentials
You cannot specify both credential_source and source_profile in the same profile.
Example of setting this in a config file to indicate that credentials should be sourced from Amazon
EC2:
credential_source = Ec2InstanceMetadata
role_arn = arn:aws:iam::123456789012:role/my-role-name
This setting applies only when the profile specifies to assume a role.
Valid values: The value can range from 900 seconds (15 minutes) up to the maximum session
duration setting configured for the role (which can be a maximum of 43200 seconds, or 12 hours).
For more information, see View the Maximum Session Duration Setting for a Role in the IAM User
Guide.
duration_seconds = 43200
Specifies a unique identifier that is used by third parties to assume a role in their customers'
accounts.
This setting applies only when the profile specifies to assume a role and the trust policy for the role
requires a value for ExternalId. The value maps to the ExternalId parameter that is passed to
the AssumeRole operation when the profile specifies a role.
Valid values: See How to use an External ID When Granting Access to Your AWS Resources to a Third
Party in the IAM User Guide.
external_id = unique_value_assigned_by_3rd_party
Specifies the identification or serial number of a multi-factor authentication (MFA) device that the
user must use when assuming a role.
Required when assuming a role where the trust policy for that role includes a condition that requires
MFA authentication.
Valid values: The value can be either a serial number for a hardware device (such as
GAHT12345678), or an Amazon Resource Name (ARN) for a virtual MFA device. For more information
about MFA, see Configuring MFA-Protected API Access in the IAM User Guide.
24
AWS SDKs and Tools Reference Guide
Assume role credentials
mfa_serial = arn:aws:iam::123456789012:mfa/my-user-name
Specifies the Amazon Resource Name (ARN) of an IAM role that you want to use to perform
operations requested using this profile.
Valid values: The value must be the ARN of an IAM role, formatted as follows:
arn:aws:iam::account-id:role/role-name
role_arn = arn:aws:iam::123456789012:role/my-role-name
source_profile = profile-with-user-that-can-assume-role
role_arn = arn:aws:iam::123456789012:role/my-role-name
credential_source = Ec2InstanceMetadata
Specifies the name to attach to the role session. This name appears in AWS CloudTrail logs for
entries associated with this session.
Default value: An optional parameter. If you don't provide this value, a session name is generated
automatically if the profile assumes a role.
Valid values: Provided to the RoleSessionName parameter when the AWS CLI calls the
AssumeRole operation (or operations such as the AssumeRoleWithWebIdentity operation) on
your behalf. The value becomes part of the assumed role user Amazon Resource Name (ARN) that
you can query, and shows up as part of the CloudTrail log entries for operations invoked by this
profile.
arn:aws:sts::123456789012:assumed-role/my-role-name/my-role_session_name.
role_session_name = my-role-session-name
Specifies another profile whose credentials are used to assume the role specified by the role_arn
setting in the original profile. To understand how profiles are used in the shared AWS config and
credentials files, see Shared config and credentials files (p. 2).
If you specify a profile that is also an assume role profile, each role will be assumed in sequential
order to fully resolve the credentials. This chain is stopped when the SDK encounters a profile with
25
AWS SDKs and Tools Reference Guide
Assume role credentials
static credentials. Role chaining limits your AWS CLI or AWS API role session to a maximum of one
hour and can't be increased. For more information, see Roles terms and concepts in the IAM User
Guide.
Valid values: A text string that consists of the name of a profile defined in the config and
credentials files. You must also specify a value for role_arn in the current profile.
Note
This setting is an alternative to credential_source. You can't specify both
source_profile and credential_source in the same profile.
[profile A]
source_profile = B
role_arn = arn:aws:iam::123456789012:role/RoleA
[profile B]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Specifies the path to a file that contains an access token from a supported OAuth 2.0 provider or
OpenID Connect ID identity provider.
This setting enables authentication by using web identity federation providers, such as
Google, Facebook, and Amazon, among many others. The SDK or developer tool loads the
contents of this file and passes it as the WebIdentityToken argument when it calls the
AssumeRoleWithWebIdentity operation on your behalf.
Valid values: This value must be a path and file name. The file must contain an OAuth 2.0 access
token or an OpenID Connect token that was provided to you by an identity provider.
[profile web-identity]
role_arn=arn:aws:iam::123456789012:role/my-role-name
web_identity_token_file=/path/to/a/token
SDK Supported
Notes or more information
26
AWS SDKs and Tools Reference Guide
Container credentials
SDK Supported
Notes or more information
Container credentials
The container credential provider fetches credentials for customer’s containerized application. This
credential provider is useful for Amazon Elastic Container Service (Amazon ECS) customers. SDKs will
attempt to load credentials from the specified HTTP endpoint through a GET request.
Contains the full HTTP URL endpoint for the SDK to use when making a request for credentials. This
includes both the scheme and the host.
export AWS_CONTAINER_CREDENTIALS_FULL_URI=http://localhost/get-credentials
or
export AWS_CONTAINER_CREDENTIALS_FULL_URI=http://localhost:8080/get-credentials
Specifies the relative HTTP URL endpoint for the SDK to use when making a request for credentials.
27
AWS SDKs and Tools Reference Guide
IMDS credentials
export AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=/get-credentials?a=1
If this variable is set, the SDK will set the Authorization header on the HTTP request with the
environment variable's value.
export AWS_CONTAINER_CREDENTIALS_FULL_URI=http://localhost/get-credential
export AWS_CONTAINER_AUTHORIZATION_TOKEN=Basic abcd
SDK Supported
Notes or more information
IMDS credentials
Instance metadata is data about your instance that you can use to configure or manage the running
instance. For more information about the data available, see Instance metadata and user data in the
Amazon EC2 User Guide for Linux Instances or Instance metadata and user data in the Amazon EC2 User
Guide for Windows Instances. Amazon EC2 provides a local endpoint available to instances that can
provide various bits of information to the instance. If the instance has a role attached, it can provide a set
28
AWS SDKs and Tools Reference Guide
IMDS credentials
of credentials that are valid for that role. The SDKs can use that endpoint to resolve credentials as part of
their default credential provider chain (p. 23).
Whether or not to attempt to use Amazon EC2 Instance Metadata Service (IMDS) to obtain
credentials.
Default value:IPv4.
Customers using Linux or macOS can set this environment variable with the following command:
$ export AWS_EC2_METADATA_DISABLED=true
If you want this setting to be persistent across multiple shell sessions and system restarts, you can add
the above command to your shell profile file, such as .bash_profile, .zsh_profile, or .profile.
29
AWS SDKs and Tools Reference Guide
Process credentials
Windows
Customers using Windows can set this environment variable with the following command:
$ set AWS_EC2_METADATA_DISABLED=true
If you want this setting to be persistent across multiple shell sessions and system restarts can use the
following command instead:
$ setx AWS_EC2_METADATA_DISABLED=true
Note
The setx command does not apply the value to the current shell session, so you will need to
reload or reopen the shell for the change to take effect.
SDK Supported
Notes or more information
Process credentials
SDKs provide a way to extend the credential provider chain for custom use cases.
Warning
The following describes a method of sourcing credentials from an external process. This can
potentially be dangerous, so proceed with caution. Other credential providers should be
preferred if at all possible. If using this option, you should make sure that the config file is as
locked down as possible using security best practices for your operating system. Confirm that
your custom credential tool does not write any secret information to StdErr, because the SDKs
and AWS CLI can capture and log such information, potentially exposing it to unauthorized
users.
30
AWS SDKs and Tools Reference Guide
Process credentials
Specifies an external command that the SDK or tool runs on your behalf to generate or retrieve
authentication credentials to use. The setting specifies the name of a program/command that the
SDK will invoke. When the SDK invokes the process, it waits for the process to write JSON data
to stdout. The custom provider must return information in a specific format. That information
contains the credentials that the SDK or tool can use to authenticate you.
• The path and file name can consist of only these characters: A-Z, a-z, 0-9, hyphen ( - ), underscore ( _ ),
period ( . ), forward slash ( / ), backslash ( \ ), and space.
• If the path or file name contains a space, surround the complete path and file name with double-
quotation marks (" ").
• If a parameter name or a parameter value contains a space, surround that element with double-
quotation marks (" "). Surround only the name or value, not the pair.
• Don't include any environment variables in the strings. For example, don't include $HOME or
%USERPROFILE%.
• Don't specify the home folder as ~. * You must specify either the full path or a base file name. If there
is a base file name, the system attempts to find the program within folders specified by the PATH
environment variable.
{
"Version": 1,
"AccessKeyId": "an AWS access key",
"SecretAccessKey": "your AWS secret access key",
"SessionToken": "the AWS session token for temporary credentials",
"Expiration": "RFC3339 timestamp for when the credentials expire"
}
Note
As of this writing, the Version key must be set to 1. This might increment over time as the
structure evolves.
31
AWS SDKs and Tools Reference Guide
SSO credentials
The Expiration key is an RFC3339 formatted timestamp. If the Expiration key isn't present in
the tool's output, the SDK assumes that the credentials are long-term credentials that don't refresh.
Otherwise, the credentials are considered temporary credentials, and they are automatically refreshed by
rerunning the credential_process command before the credentials expire.
Note
The SDK does not cache external process credentials the way it does assume-role credentials. If
caching is required, you must implement it in the external process.
The external process can return a non-zero return code to indicate that an error occurred while retrieving
the credentials.
SDK Supported
Notes or more information
SSO credentials
Prerequisites
You must first enable SSO authentication within AWS IAM Identity Center (successor to AWS Single
Sign-On). For an overview of that process, see Single sign-on (SSO) (p. 12) in this guide. For details, see
Getting Started in the AWS IAM Identity Center (successor to AWS Single Sign-On) User Guide.
Profile Configuration
After AWS IAM Identity Center (successor to AWS Single Sign-On) is enabled, you need to define a profile
for SSO settings in your shared AWS config file. These profiles are used to connect to the IAM Identity
Center access portal. After a user successfully authenticates with IAM Identity Center, the portal returns
short-term credentials for the IAM role associated with that user.
32
AWS SDKs and Tools Reference Guide
SSO credentials
The user portal for a profile is specified with the sso_start_url and sso_region settings. The
permissions are specified with the sso_account_id and sso_role_name settings. All four settings are
required.
• AWS IAM Identity Center (successor to AWS Single Sign-On) User Guide
• AWS IAM Identity Center (successor to AWS Single Sign-On) Portal API Reference
To learn more about configuring and signing in to IAM Identity Center through the AWS CLI, see
Configuring the AWS CLI to use AWS IAM Identity Center (successor to AWS Single Sign-On) in the AWS
Command Line Interface User Guide.
The URL that points to your organization's IAM Identity Center access portal. For more information
on the IAM Identity Center access portal, see Using the AWS access portal in the AWS IAM Identity
Center (successor to AWS Single Sign-On) User Guide. To find this value, open the IAM Identity Center
console, view the Dashboard, and find AWS access portal URL.
sso_region - shared AWS config file setting
The AWS Region that contains your IAM Identity Center portal host; that is, the Region you selected
before enabling IAM Identity Center. This can be different from your default AWS Region.
For a complete list of the AWS Regions and their codes, see Regional Endpoints in the Amazon
Web Services General Reference. To find this value, open the IAM Identity Center console, view the
Dashboard, and find Region.
sso_account_id - shared AWS config file setting
The 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 the IAM Identity Center console and
open the AWS accounts page.
sso_role_name - shared AWS config file setting
The role name or permission set of the IAM role that defines the user's resulting permissions. The
role must exist in the AWS account specified by sso_account_id. Use the role name, not the role
Amazon Resource Name (ARN).
Depending on whether you log into the IAM Identity Center access portal as an administrator or
a user, this value may be an permission set or a role name. 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 the IAM Identity Center console
and open the AWS accounts page. Choose the correct permission set name listed in the AWS
accounts table.
[profile my-sso-profile]
sso_start_url = https://my-sso-portal.awsapps.com/start
sso_region = us-west-2
sso_account_id = 111122223333
sso_role_name = SSOReadOnlyRole
33
AWS SDKs and Tools Reference Guide
Static credentials
SDK Supported
Notes or more information
SDK for Java 2.x Yes Configuration values also supported in credentials file.
Static credentials
For basics on static credentials, see AWS account root user credentials and IAM user credentials and
Understanding and getting your AWS credentials in the Amazon Web Services General Reference.
The AWS SDK automatically uses these AWS credentials to sign API requests to AWS, so that your
workloads can access your AWS resources and data securely and conveniently. If you use an IAM role,
these temporary AWS credentials are refreshed multiple times a day.
Note
If AWS becomes unable to refresh these temporary credentials, AWS may extend the validity of
the credentials so that your workloads are not impacted.
The shared AWS credentials file is the recommended location for storing credentials information
because it is safely outside of application source directories and separate from the SDK-specific settings
of the shared config file.
Specifies the AWS access key used as part of the credentials to authenticate the user.
aws_secret_access_key - shared AWS config file setting, aws_secret_access_key - shared
AWS credentials file setting (recommended method), AWS_SECRET_ACCESS_KEY - environment
variable
Specifies the AWS secret key used as part of the credentials to authenticate the user.
34
AWS SDKs and Tools Reference Guide
Static credentials
Specifies an AWS session token used as part of the credentials to authenticate the user. A session
token is required only if you manually specify temporary security credentials. You receive this value
as part of the temporary credentials returned by successful requests to assume a role.
[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
aws_session_token = AQoEXAMPLEH4aoAH0gNCAPy...truncated...zrkuWJOgQs8IZZaIv2BXIa2R4Olgk
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
export
AWS_SESSION_TOKEN=AQoEXAMPLEH4aoAH0gNCAPy...truncated...zrkuWJOgQs8IZZaIv2BXIa2R4Olgk
SDK Supported
Notes or more information
35
AWS SDKs and Tools Reference Guide
Standardized features
Standardized features
Many features have been standardized to consistent defaults and to work the same way across many
SDKs. This consistency increases productivity and clarity when coding across multiple SDKs. All settings
can be overridden in code, see your specific SDK API for details.
Important
Not all SDKs support all features, or even all aspects within a feature.
Topics
• Amazon EC2 instance metadata (p. 36)
• Amazon S3 access points (p. 37)
• Amazon S3 Multi-Region Access Points (p. 38)
• AWS Region (p. 40)
• AWS STS Regionalized endpoints (p. 41)
• Endpoint discovery (p. 43)
• General configuration settings (p. 44)
• IMDS client (p. 46)
• Retry behavior (p. 48)
• Smart configuration defaults (p. 50)
This setting specifies the number of total attempts to make before giving up when attempting to
retrieve data from the instance metadata service.
Default value: 1
Specifies the number of seconds before timing out when attempting to retrieve data from the
instance metadata service.
Default value: 1
[default]
36
AWS SDKs and Tools Reference Guide
Amazon S3 access points
metadata_service_num_attempts=10
metadata_service_timeout=10
export AWS_METADATA_SERVICE_NUM_ATTEMPTS=10
export AWS_METADATA_SERVICE_TIMEOUT=10
setx AWS_METADATA_SERVICE_NUM_ATTEMPTS 10
setx AWS_METADATA_SERVICE_TIMEOUT 10
SDK Supported
Notes or more information
To learn more about Amazon S3 access points and ARNs, see Using access points in the Amazon S3 User
Guide.
37
AWS SDKs and Tools Reference Guide
Amazon S3 Multi-Region Access Points
This setting controls whether the SDK uses the access point ARN AWS Region to construct the
Regional endpoint for the request. The SDK validates that the ARN AWS Region is served by the
same AWS partition as the client's configured AWS Region to prevent cross-partition calls that most
likely will fail. If multiply defined, the code-configured setting takes precedence, followed by the
environment variable setting.
Valid values:
• true – The SDK uses the ARN's AWS Region when constructing the endpoint instead of the client's
configured AWS Region. Exception: If the client's configured AWS Region is a FIPS AWS Region,
then it must match the ARN's AWS Region. Otherwise, an error will result.
• false – The SDK uses the client's configured AWS Region when constructing the endpoint.
SDK Supported
Notes or more information
38
AWS SDKs and Tools Reference Guide
Amazon S3 Multi-Region Access Points
To learn more about Multi-Region Access Points, see Multi-Region Access Points in Amazon S3 in the
Amazon S3 User Guide.
To learn more about Multi-Region Access Point Amazon Resource Names (ARNs), see Making requests
using a Multi-Region Access Point in the Amazon S3 User Guide.
To learn more about creating Multi-Region Access Points, see Managing Multi-Region Access Points in the
Amazon S3 User Guide.
The SigV4A algorithm is the signing implementation used to sign the global Region requests. This
algorithm is obtained by the SDK through a dependency on the AWS Common Runtime (CRT)
libraries (p. 53).
This setting controls whether the SDK potentially attempts cross-Region requests. If multiply
defined, the code-configured setting takes precedence, followed by the environment variable
setting.
Valid values:
• true – Stops the use of cross-Region requests.
• false – Enables cross-Region requests using Multi-Region Access Points.
SDK Supported
Notes or more information
39
AWS SDKs and Tools Reference Guide
AWS Region
SDK Supported
Notes or more information
AWS Region
AWS Regions are an important concept to understand when working with AWS services.
With AWS Regions, you can access AWS services that physically reside in a specific geographic area. This
can be useful to keep your data and applications running close to where you and your users will access
them. Regions provide fault tolerance, stability, and resilience, and can also reduce latency. With Regions,
you can create redundant resources that remain available and unaffected by a Regional outage.
Most AWS service requests are associated with a particular geographic region. The resources that you
create in one Region do not exist in any other Region unless you explicitly use a replication feature
offered by an AWS service. For example, Amazon S3 and Amazon EC2 support cross-Region replication.
Some services, such as IAM, do not have Regional resources.
• To understand the relationship between Regions and endpoints, and to view a list of existing Regional
endpoints, see AWS service endpoints.
• To view the current list of all supported Regions and endpoints for each AWS service, see Service
endpoints and quotas.
To programmatically access AWS services, SDKs use a client class/object for each AWS service. If your
application needs to access Amazon EC2, for example, your application would create an Amazon EC2
client object to interface with that service.
If no Region is explicitly specified for the client, the client defaults to using the Region set through the
following region setting. However, the active Region for a client can be explicitly set for any individual
client object. Setting the Region in this way takes precedence over any global setting for that particular
service client. The alternative Region is specified during instantiation of that client, specific to your SDK
(check your specific SDK Guide or your SDK's code base).
Specifies the default AWS Region to use for AWS requests. This Region is used for SDK service
requests that aren't provided with a specific Region to use.
Valid values:
• Any of the Region codes available for the chosen service, as listed in AWS service endpoints in the
AWS General Reference. For example, the value us-east-1 sets the endpoint to the AWS Region
US East (N. Virginia).
• aws-global specifies the global endpoint for services that support a separate global endpoint
in addition to Regional endpoints, such as AWS Security Token Service (AWS STS) and Amazon
Simple Storage Service (Amazon S3).
40
AWS SDKs and Tools Reference Guide
AWS STS Regionalized endpoints
[default]
region = us-west-2
export AWS_REGION=us-west-2
Most SDKs have a "configuration" object that is available for setting the default Region from within the
application code. For details, see your specific AWS SDK developer guide.
SDK Supported
Notes or more information
AWS CLI v2 Yes AWS CLI V2 uses any value in AWS_REGION before any value in
AWS_DEFAULT_REGION (both variables are checked).
SDK for Python (Boto3) Yes This SDK uses environment variable named
AWS_DEFAULT_REGION for this purpose.
41
AWS SDKs and Tools Reference Guide
AWS STS Regionalized endpoints
endpoint. For more information on AWS STS endpoints, Endpoints in the AWS Security Token Service API
Reference.
This setting specifies how the SDK or tool determines the AWS service endpoint that it uses to talk
to the AWS Security Token Service (AWS STS).
Note: All new SDK major versions will default to regional in the future.
Valid values:
• legacy – Uses the global AWS STS endpoint, sts.amazonaws.com, for the following AWS
Regions: ap-northeast-1, ap-south-1, ap-southeast-1, ap-southeast-2, aws-global,
ca-central-1, eu-central-1, eu-north-1, eu-west-1, eu-west-2, eu-west-3, sa-
east-1, us-east-1, us-east-2, us-west-1, and us-west-2. All other Regions automatically
use their respective Regional endpoint.
• regional – The SDK or tool always uses the AWS STS endpoint for the currently configured
Region. For example, if the client is configured to use us-west-2, all calls to AWS STS are
made to the Regional endpoint sts.us-west-2.amazonaws.com, instead of the global
sts.amazonaws.com endpoint. To send a request to the global endpoint while this setting is
enabled, you can set the Region to aws-global.
[default]
sts_regional_endpoints = regional
export AWS_STS_REGIONAL_ENDPOINTS=regional
SDK Supported
Notes or more information
SDK for C++ PartialEnvironment variable and config file setting not supported. SDK
performs with regional setting.
42
AWS SDKs and Tools Reference Guide
Endpoint discovery
SDK Supported
Notes or more information
Endpoint discovery
SDKs use endpoint discovery to access service endpoints (URLs to access various resources), while still
maintaining flexibility for AWS to alter URLs as needed. This way, your code can automatically detect
new endpoints. There are no fixed endpoints for some services. Instead, you get the available endpoints
during runtime by making a request to get the endpoints first. After retrieving the available endpoints,
the code then uses the endpoint to access other operations. For example, for Amazon Timestream, the
SDK makes a DescribeEndpoints request to retrieve the available endpoints, and then uses those
endpoints to complete specific operations such as CreateDatabase or CreateTable.
Endpoint discovery is required in some services and optional in others. It defaults to either true
or false depending on whether the service requires endpoint discovery. For example, Timestream
defaults to true, and Amazon DynamoDB defaults to false. For services where endpoint discovery is
not required, endpoint discovery is not enabled. Instead, configuration options are available through
environment variables, the shared AWS config file, or SDK code constructs (for example, configuration
classes). For operations where endpoint discovery is required, the SDK automatically attempts to discover
an endpoint.
Enables/disables endpoint discovery for services where endpoint discovery is optional. Endpoint
discovery is required in some services.
Valid values:
• true – The SDK should automatically attempt to discover an endpoint for services where
endpoint discovery is optional.
• false – The SDK should not automatically attempt to discover an endpoint for services where
endpoint discovery is optional.
43
AWS SDKs and Tools Reference Guide
General configuration
SDK Supported
Notes or more information
Some AWS services maintain multiple API versions to support backward compatibility. By default,
SDK and AWS CLI operations use the latest available API version. To require a specific API version to
use for your requests, include the api_versions setting in your profile.
Valid values: This is a nested setting that's followed by one or more indented lines that each
identify one AWS service and the API version to use. See the documentation for the AWS service to
understand which API versions are available.
The example sets a specific API version for two AWS services in the config file. These API versions
are used only for commands that run under the profile that contains these settings. Commands for
any other service use the latest version of that service's API.
api_versions =
ec2 = 2015-03-01
cloudfront = 2015-09-017
Specifies the path to a custom certificate bundle (a file with a .pem extension) to use when
establishing SSL/TLS connections.
44
AWS SDKs and Tools Reference Guide
General configuration
Valid values: Specify either the full path or a base file name. If there is a base file name, the system
attempts to find the program within folders specified by the PATH environment variable.
[default]
ca_bundle = dev/apps/ca-certs/cabundle-2019mar05.pem
export AWS_CA_BUNDLE=/dev/apps/ca-certs/cabundle-2019mar05.pem
Specifies whether the SDK or tool attempts to validate command line parameters before sending
them to the AWS service endpoint.
Valid values:
• true – The default. The SDK or tool performs client-side validation of command line parameters.
This helps the SDK or tool confirm that parameters are valid, and catches some errors. The SDK or
tool can reject requests that aren't valid before sending requests to the AWS service endpoint.
• false – The SDK or tool doesn't validate command line parameters before sending them to the
AWS service endpoint. The AWS service endpoint is responsible for validating all requests and
rejecting requests that aren't valid.
SDK Supported
Notes or more information
45
AWS SDKs and Tools Reference Guide
IMDS client
SDK Supported
Notes or more information
IMDS client
SDKs implement an Instance Metadata Service Version 2 (IMDSv2) client using session-oriented requests.
For more information on IMDSv2, see Use IMDSv2 in the Amazon EC2 User Guide for Linux Instances or
Use IMDSv2 in the Amazon EC2 User Guide for Windows Instances. The IMDS client is configurable via a
client configuration object available in the SDK code base.
Default value: 3
Default value: 80
The following options are supported by most SDKs. See your specific SDK code base for details.
46
AWS SDKs and Tools Reference Guide
IMDS client
The number of seconds to sleep in between retries or a customer provided backoff function to call.
This overrides the default exponential backoff strategy.
Valid values: Varies by SDK. Can be either a numeric value or a call out to a custom function.
SDK Supported
Notes or more information
47
AWS SDKs and Tools Reference Guide
Retry behavior
SDK Supported
Notes or more information
Retry behavior
Retry behavior includes settings regarding how the SDKs attempt to recover from failures resulting from
requests made to AWS services.
Default value: If this value is not specified, its default depends on the value of the retry_mode
setting:
• If retry_mode is legacy – Uses a default value specific to your SDK (check your specific SDK
guide or your SDK's code base for max_attempts default).
• If retry_mode is standard – Makes three attempts.
• If retry_mode is adaptive – Makes three attempts.
Valid values:
• legacy – Specific to your SDK (check your specific SDK guide or your SDK's code base).
• standard – The standard set of retry rules across AWS SDKs. This mode includes a standard set
of errors that are retried, and support for retry quotas. The default maximum number of attempts
with this mode is three, unless max_attempts is explicitly configured.
• adaptive – An experimental retry mode that includes the functionality of standard mode but
includes automatic client-side throttling. Because this mode is experimental, it might change
behavior in the future.
Following is the high-level pseudocode for both the standard and adaptive retry modes:
MakeSDKRequest() {
attempts = 0
loop {
GetSendToken()
response = SendHTTPRequest()
RequestBookkeeping(response)
if not Retryable(response)
return response
attempts += 1
if attempts >= MAX_ATTEMPTS:
return response
if not HasRetryQuota(response)
return response
delay = ExponentialBackoff(attempts)
sleep(delay)
}
48
AWS SDKs and Tools Reference Guide
Retry behavior
Following are more details about the components used in the pseudocode:
GetSendToken:
Token buckets are only used in adaptive retry mode. Token buckets enforce a maximum request rate
by requiring a token to be available in order to initiate a request. The SDK client is configurable to either
fast fail the request or block until a token becomes available.
Client Side Rate Limiting is an algorithm that initially lets requests be made at any rate up to the token
allowance. However, after a throttled response is detected, the client rate-of-request is then limited
accordingly. The token allowance is also increased accordingly if successful responses are received.
With adaptive rate limiting, SDKs can slow down the rate at which requests are sent in order to better
accommodate the capacity of AWS services.
SendHTTPRequest:
Most AWS SDKs use an HTTP library that uses connection pools so that you can reuse an existing
connection when making an HTTP request. Generally, connections are reused when retrying requests due
to throttling errors. Requests are not reused when retrying due to transient errors.
RequestBookkeeping:
The retry quota should be updated if the request is successful. For adaptive retry mode only, the state
variable maxsendrate is updated based on the type of response received.
Retryable:
This step determines whether a response can be retried based on the following:
Transient errors (HTTP status codes 400, 408, 500, 502, 503, and 504) and throttling errors (HTTP status
codes 400, 403, 429, 502, 503, and 509) can all be retried.
MAX_ATTEMPTS:
HasRetryQuota
This step throttles retry requests by requiring a token to be available in the retry quota bucket. Retry
quota buckets are a mechanism to prevent retries that are unlikely to succeed. These quotas are SDK-
dependent, are often client-dependent, and are sometimes even dependent on service endpoints. The
available retry quota tokens are removed when requests fail for various reasons, and replenished when
they succeed. When no tokens remain, the retry loop is exited.
ExponentialBackoff
For an error that can be retried, the retry delay is calculated using truncated exponential backoff. The
SDKs use truncated binary exponential backoff with jitter. The following algorithm shows how the
amount of time to sleep, in seconds, is defined for a response for request i:
49
AWS SDKs and Tools Reference Guide
Smart configuration defaults
r = 2
MAX_BACKOFF = 20 seconds for most SDKs. See your specific SDK guide or source code for
confirmation.
SDK Supported
Notes or more information
With this setting, you can choose a mode that aligns with your application architecture, which
then provides optimized default values for your application. If an AWS SDK setting has a value
explicitly set, then that value always takes precedence. If an AWS SDK setting does not have a
value explicitly set, and defaults_mode is not equal to legacy, then this feature can provide
different default values for various settings optimized for your application. Settings may include
the following: HTTP communication settings, retry behavior, service Regional endpoint settings,
and, potentially, any SDK-related configuration. Customers who use this feature can get new
configuration defaults tailored to common usage scenarios. If your defaults_mode is not equal to
legacy, we recommend performing tests of your application when you upgrade the SDK, because
the default values provided might change as best practices evolve.
50
AWS SDKs and Tools Reference Guide
Smart configuration defaults
Valid values:
• legacy – Provides default settings that vary by SDK and existed before establishment of
defaults_mode.
• standard – Provides the latest recommended default values that should be safe to run in most
scenarios.
• in-region – Builds on the standard mode and includes optimization tailored for applications
that call AWS services from within the same AWS Region.
• cross-region – Builds on the standard mode and includes optimization tailored for applications
that call AWS services in a different Region.
• mobile – Builds on the standard mode and includes optimization tailored for mobile applications.
• auto – Builds on the standard mode and includes experimental features. The SDK attempts to
discover the runtime environment to determine the appropriate settings automatically. The auto
detection is heuristics-based and does not provide 100% accuracy. If the runtime environment
can't be determined, standard mode is used. The auto detection might query Instance metadata
and user data, which might introduce latency. If startup latency is critical to your application, we
recommend choosing an explicit defaults_mode instead.
[default]
defaults_mode = standard
The default value for each setting changes depending on the defaults_mode selected for your
application. These values are currently set as follows (subject to change):
stsRegionalEndpoints
regional regional regional regional
s3UsEast1RegionalEndpoints
regional regional regional regional
3100
connectTimeoutInMillis 1100 3100 30000
51
AWS SDKs and Tools Reference Guide
Smart configuration defaults
3100
tlsNegotiationTimeoutInMillis 1100 3100 30000
For example, if the defaults_mode you selected was standard, then the value of standard would be
assigned for retry_mode (from the valid retry_mode options) and the value of regional would be
assigned for stsRegionalEndpoints (from the valid stsRegionalEndpoints options).
AWS CLI v2 No
52
AWS SDKs and Tools Reference Guide
CRT dependencies
CRT dependencies
The CRT libraries form a complex net of relationships and dependencies. Knowing these relationships is
helpful if you need to build the CRT directly from source. However, most users access CRT functionality
through their language SDK (such as AWS SDK for C++ or AWS SDK for Java) or their language IoT device
SDK (such as AWS IoT SDK for C++ or AWS IoT SDK for Java). In the following diagram, the Language
CRT Bindings box refers to the package wrapping the CRT libraries for a specific language SDK. This is a
collection of packages of the form aws-crt-*, where '*' is an SDK language (such as aws-crt-cpp or
aws-crt-java).
The following is a visual illustration of the hierarchical dependencies of the CRT libraries.
53
AWS SDKs and Tools Reference Guide
Maintenance policy
The following topics cover the maintenance and version support policies for AWS SDKs.
Topics
• AWS SDKs and Tools maintenance policy (p. 54)
• AWS SDKs and Tools version support matrix (p. 56)
We recommend users to stay up-to-date with SDK releases to keep up with the latest features,
security updates, and underlying dependencies. Continued use of an unsupported SDK version is not
recommended and is done at the user’s discretion.
Versioning
The AWS SDK release versions are in the form of X.Y.Z where X represents the major version. Increasing
the major version of an SDK indicates that this SDK underwent significant and substantial changes to
support new idioms and patterns in the language. Major versions are introduced when public interfaces
(e.g. classes, methods, types, etc.), behaviors, or semantics have changed. Applications need to be
updated in order for them to work with the newest SDK version. It is important to update major versions
carefully and in accordance with the upgrade guidelines provided by AWS.
• Developer Preview (Phase 0) - During this phase, SDKs are not supported, should not be used in
production environments, and are meant for early access and feedback purposes only. It is possible for
future releases to introduce breaking changes. Once AWS identifies a release to be a stable product,
it may mark it as a Release Candidate. Release Candidates are ready for GA release unless significant
bugs emerge, and will receive full AWS support.
• General Availability (GA) (Phase 1) - During this phase, SDKs are fully supported. AWS will provide
regular SDK releases that include support for new services, API updates for existing services, as well as
bug and security fixes. For Tools, AWS will provide regular releases that include new feature updates
and bug fixes. AWS will support the GA version of an SDK for at least 24 months.
54
AWS SDKs and Tools Reference Guide
Dependency life-cycle
• Maintenance Announcement (Phase 2) - AWS will make a public announcement at least 6 months
before an SDK enters maintenance mode. During this period, the SDK will continue to be fully
supported. Typically, maintenance mode is announced at the same time as the next major version is
transitioned to GA.
• Maintenance (Phase 3) - During the maintenance mode, AWS limits SDK releases to address critical
bug fixes and security issues only. An SDK will not receive API updates for new or existing services, or
be updated to support new regions. Maintenance mode has a default duration of 12 months, unless
otherwise specified.
• End-of-Support (Phase 4) - When an SDK reaches end-of support, it will no longer receive updates
or releases. Previously published releases will continue to be available via public package managers
and the code will remain on GitHub. The GitHub repository may be archived. Use of an SDK which has
reached end-of-support is done at the user’s discretion. We recommend users upgrade to the new
major version.
The following is a visual illustration of the SDK major version life-cycle. Please note that the timelines
shown below are illustrative and not binding.
Dependency life-cycle
Most AWS SDKs have underlying dependencies, such as language runtimes, operating systems, or third
party libraries and frameworks. These dependencies are typically tied to the language community or the
vendor who owns that particular component. Each community or vendor publishes their own end-of-
support schedule for their product.
The following terms are used to classify underlying third party dependencies:
• Operating System (OS): Examples include Amazon Linux AMI, Amazon Linux 2, Windows 2008,
Windows 2012, Windows 2016, etc.
• *Language Runtime:* Examples include Java 7, Java 8, Java 11, .NET Core, .NET Standard, .NET PCL,
etc.
• *Third party Library / Framework: Examples include OpenSSL, .NET Framework 4.5, Java EE, etc.
Our policy is to continue supporting SDK dependencies for* at least 6 months* after the community or
vendor ends support for the dependency. This policy, however, could vary depending on the specific
dependency.
Note
AWS reserves the right to stop support for an underlying dependency without increasing the
major SDK version
Communication methods
Maintenance announcements are communicated in several ways:
• An email announcement is sent to affected accounts, announcing our plans to end support for
the specific SDK version. The email will outline the path to end-of-support, specify the campaign
timelines, and provide upgrade guidance.
• AWS SDK documentation, such as API reference documentation, user guides, SDK product marketing
pages, and GitHub readme(s) are updated to indicate the campaign timeline and provide guidance on
upgrading affected applications.
• An AWS blog post is published that outlines the path to end-of-support, as well as reiterates the
campaign timelines.
• Deprecation warnings are added to the SDKs, outlining the path to end-of-support and linking to the
SDK documentation.
55
AWS SDKs and Tools Reference Guide
Version support matrix
To see the list of available major versions of AWS SDKs and Tools and where they are in their
maintenance life cycle, see the section called “Version support matrix” (p. 56).
56
AWS SDKs and Tools Reference Guide
Version support matrix
57
AWS SDKs and Tools Reference Guide
Service name change for single- Updates to reflect that AWS SSO July 26, 2022
sign on (p. 58) is now referred to as AWS IAM
Identity Center (successor to
AWS Single Sign-On).
Settings update (p. 58) Minor updates to config file June 15, 2022
details and to supported
settings.
Initial release (p. 58) The first release of this guide is March 13, 2020
released to the public.
58
AWS SDKs and Tools Reference Guide
AWS glossary
For the latest AWS terminology, see the AWS glossary in the AWS General Reference.
59