The document provides an overview of the AWS SDK for C++, including its core features such as credential management, asynchronous requests, rate limiting, error handling, and memory allocation. It also discusses how to override the HTTP/TLS stack and integrate high-level APIs. The presentation encourages attendees to contribute high-level APIs and send pull requests to the SDK's GitHub repository.
2. Agenda
• Overview of the AWS SDK for C++
• github.com/awslabs/aws-sdk-cpp
• Core library features
• Credential management
• Logging
• Asynchronous requests
• Rate limiting
• Error handling
• Memory allocation
• Streaming
• Overriding the HTTP/TLS stack
• High-level APIs overview
3. Getting started
What is it?
• Modern C++ language bindings for AWS
• Generated service clients + high-level APIs
Source
• github.com/awslabs/aws-sdk-cpp
Build Prerequisites
• C++11-compatible compiler
• CMake
• A HTTP/TLS implementation for your platform
– We ship Curl, WinHTTP, and WinINet interfaces
10. Async
• All generated operations have an async version
• Async requests notify your callback function
• Callback receives client, request, outcome, and
optional context objects
• Pluggable custom executor for more control
13. Asynchronous executor
• Default executor will spawn a detached thread
• Implement executor for more control
• Use this to tie asynchronous calls to your system’s
custom thread pool
16. Rate limiting
• Client-side bandwidth throttling at the HTTP layer
• Configurable separately for each client and each
directionality (uploads and downloads)
19. Rate limiting
Recommendations and things to know:
• Default rate limiter implementation probably does what
you want. (#include
<aws/core/utils/ratelimiter/DefaultRateLimiter.h> )
• Calculation made at IO time not request size.
20. Error handling
• No exceptions used internally or thrown externally
• Performance and flexibility reasons
• SDK is exception-safe
• Exceptions are safe to use in your application
21. Error handling
• Requests return an ‘Outcome’ object.
• An ‘Outcome’ is either successful with a result payload
or unsuccessful with an error payload
• Errors closely match exception names from other
SDKs
26. Memory allocation
• Configured at compile time
• Custom Allocators installed at runtime
• Default forces allocation into single allocator
• On by default for dynamic libraries
• What about the STL?
29. Memory allocation
What about the Standard Template Library?
• Use AWS-defined STL types (Aws::Vector, Aws::String,
Aws::Map, Aws::IOStream, etc.)
• Automatically resolves allocator
• Compile time switch
• Most APIs take primitives as well
30. Memory allocation
General advice
• Use custom memory management with dynamic
linking -- especially on Windows
• Do not use STL containers directly
• Do not use new or delete directly
• Do not use std smart pointer APIs directly
• Use –DAWS_CUSTOM_MEMORY_MANAGEMENT
w/ custom memory management
31. Streaming requests and responses
• Some payloads are not typed (example: Amazon S3
GetObject, PutObject)
• Use the STL IOStream interface.
• Defaults to underlying StringBuf
• Easily overridable
34. Overriding the HTTP/TLS stack
I want to use my own IO stack. What do I do?
• HTTP stacks can be injected into clients
• Implement your own HttpClient
• Simply override the HttpClientFactory in your
ClientConfiguration
37. Overriding the Http/TLS stack
1 auto httpClientFactory = Aws::MakeShared<LibUVWithSignalToNoiseHttpClientFactory>(“re:InventSample”);
2 DynamoDBClient client(credentialProvider, config, httpClientFactory);
38. High-level APIs
• Amazon Cognito identity providers
• Amazon S3 Transfer Manager
• Queues-like interface for Amazon SQS
• Access management API for IAM
39. High-level APIs
1 auto credentialsProvider =
2 Aws::MakeShared<CognitoCachingAnonymousCredentialsProvider>(“re:invent sample”,
3 “55216815”, “us-east-1:65814ddc-1479-4dfe-9bab-254541asd2fb”);
4
5 DynamoDBClient dynamoDbClient(credentialsProvider);
6
Identity management with an anonymous identity pool
40. High-level APIs
1 auto identityProvider =
2 Aws::MakeShared<DefaultPersistentCognitoIdentityProvider>(“re:invent sample”);
3 Aws::Map<Aws::String, LoginAccessTokens> tokens;
4 tokens[“www.amazon.com”] = LoginAccessTokens { “aegedeev”, “bdekibnkoga”, ONE_HOUR };
5 identityProvider->PersistLogins(tokens);
6
7 auto credentialsProvider =
8 Aws::MakeShared<CognitoCachingAuthenticatedCredentialsProvider>(“re:invent sample”,
9 “55216815”, “us-east-1:65814ddc-1479-4dfe-9bab-254541asd2fb”,
10 identityProvider);
11 DynamoDBClient dynamoDbClient(credentialsProvider);
Identity management with an authenticated identity pool
41. High-level APIs
1 auto s3Client = Aws::MakeShared<S3Client>(“re:invent sample”);
2 TransferClient transferClient(s3Client, TransferClientConfiguration { 10, nullptr } );
3
4 auto uploadFileRequest =
5 transferClient.UploadFile(“/home/user/customer/myDatabase.frm”,
6 “sample_bucket”, “sample_key”, “application/octet-stream”);
Uploading a large file with Transfer Manager