Authenticating the AWS SDK for C++ with AWS (original) (raw)

You must establish how your code authenticates with AWS when developing with AWS services. There are different ways in which you can configure programmatic access to AWS resources, depending on the environment and the AWS access available to you.

To choose your method of authentication and configure it for the SDK, see Authentication and access in the_AWS SDKs and Tools Reference Guide_.

We recommend that new users who are developing locally and are not given a method of authentication by their employer should set up AWS IAM Identity Center. This method includes installing the AWS CLI for ease of configuration and for regularly signing in to the AWS access portal.

If you choose this method, complete the procedure for IAM Identity Center authentication in the_AWS SDKs and Tools Reference Guide_. Afterwards, your environment should contain the following elements:

[default]  
sso_session = my-sso  
sso_account_id = 111122223333  
sso_role_name = SampleRole  
region = us-east-1  
output = json  
[sso-session my-sso]  
sso_region = us-east-1  
sso_start_url = https://provided-domain.awsapps.com/start  
sso_registration_scopes = sso:account:access  

The AWS SDK for C++ does not need additional packages (such as SSO andSSOOIDC) to be added to your application to use IAM Identity Center authentication.

Start an AWS access portal session

Before running an application that accesses AWS services, you need an active AWS access portal session for the SDK to use IAM Identity Center authentication to resolve credentials. Depending on your configured session lengths, your access will eventually expire and the SDK will encounter an authentication error. To sign in to the AWS access portal, run the following command in the AWS CLI.

aws sso login

Since you have a default profile setup, you do not need to call the command with a--profile option. If your SSO token provider configuration is using a named profile, the command is aws sso login --profile named-profile.

To test if you already have an active session, run the following AWS CLI command.

aws sts get-caller-identity

The response to this command should report the IAM Identity Center account and permission set configured in the shared config file.

Note

If you already have an active AWS access portal session and run aws sso login, you will not be required to provide credentials.

The sign-in process might prompt you to allow the AWS CLI access to your data. Because the AWS CLI is built on top of the SDK for Python, permission messages may contain variations of the botocore name.

More authentication information

Human users, also known as human identities, are the people, administrators, developers, operators, and consumers of your applications. They must have an identity to access your AWS environments and applications. Human users that are members of your organization are also known as workforce identities, that means you, the developer. Use temporary credentials when accessing AWS. You can use an identity provider for your human users to provide federated access to AWS accounts by assuming roles, which provide temporary credentials. For centralized access management, we recommend that you use AWS IAM Identity Center (IAM Identity Center) to manage access to your accounts and permissions within those accounts. For more alternatives, see the following: