AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Using Service Clients

AWS service client classes provide you with an interface to the AWS service that the class represents. Service clients follow the namespace convention Aws::Service::ServiceClient.

For example, a client for AWS Identity and Access Management is constructed using the Aws::IAM::IAMClient class. For an Amazon Simple Storage Service client, use Aws::S3::S3Client.

When you use the client classes to instantiate a service client, you must supply AWS credentials. You can do this by using the default credential provider chain, by manually passing credentials to the client directly, or by using a custom credentials provider.

For more information about setting credentials, see Providing AWS Credentials.

Using the Default Credential Provider Chain#

The following code shows how to create an Amazon DynamoDB client by using a specialized client configuration, default credential provider chain, and default HTTP client factory.

auto limiter = Aws::MakeShared<Aws::Utils::RateLimits::DefaultRateLimiter<>>(ALLOCATION_TAG, 200000);

// Create a client
ClientConfiguration config;
config.scheme = Scheme::HTTPS;
config.connectTimeoutMs = 30000;
config.requestTimeoutMs = 30000;
config.readRateLimiter = m_limiter;
config.writeRateLimiter = m_limiter;

auto client = Aws::MakeShared<DynamoDBClient>(ALLOCATION_TAG, config);

Passing Credentials Manually#

The following code shows how to use the client constructor that takes three arguments, and use the Aws::Auth::AWSCredentials class to pass your credentials manually to the constructor.

auto client = Aws::MakeShared<DynamoDBClient>(
    ALLOCATION_TAG, AWSCredentials("access_key_id", "secret_key"), config);

Using a Custom Credentials Provider#

The following code shows how to pass credentials to the Aws::MakeShared function and create a client by using one of the credential providers in the Aws::Auth namespace.

auto client = Aws::MakeShared<DynamoDBClient>(
        ALLOCATION_TAG, "identityPoolId", "accountId"), config);