AWS Blog

Introducing the AWS SDK for C++

by Jeff Barr | on | in Developers | | Comments

My colleague Jonathan Henson sent me a guest post to introduce a brand-new AWS SDK!

— Jeff;


After a long effort, we are proud to announce an open-source C++ SDK for scaling your native applications with Amazon Web Services.

The AWS SDK for C++ is a modern C++ interface with lightweight dependencies. We designed it to be fully functioning, with both low-level and high-level interfaces. However, we also wanted it to have as few dependencies as possible and to be platform-independent. At the moment, it includes support for Windows, OS X, Linux, and mobile platforms.

This SDK has been specifically designed with game developers in mind, but we have also worked hard to maintain an interface that will work for systems engineering tasks, as well as other projects that simply need the efficiency of native code.

Features

  • Works with the Standard Template Library (STL).
  • Custom memory management support.
  • C++ 11 features used and supported.
  • Builds with CMake and your native compiler toolchain.
  • Lightweight dependencies.
  • Exception-safe.
  • Extensive, configurable logging.
  • Default credentials providers.
  • Identity management through Amazon Cognito Identity.
  • High-level Amazon S3 interface through TransferClient.
  • Uses native OS APIs for cryptographic and HTTP support.

Code Samples

Storing a value in a Amazon DynamoDB table:

Aws::DynamoDB::DynamoDBClient dynamoDbClient;
PutItemRequest putItemRequest;
putItemRequest.WithTableName("TestTableName");
AttributeValue hashKeyAttribute;
hashKeyAttribute.SetS("SampleHashKeyValue");
putItemRequest.AddItem("HashKey", hashKeyAttribute);
AttributeValue valueAttribute;
valueAttribute.SetS("SampleValue");
putItemRequest.AddItem("Value", valueAttribute);
auto putItemOutcome = dynamoDbClient.PutItem(putItemRequest);

if(putItemOutcome.IsSuccess())
{
    std::cout << "PutItem Success Using IOPS " << putItemOutcome.GetResult().GetConsumedCapacity();
}
else
{
    std::cout << "PutItem failed with error " << putItemOutcome.GetError().GetMessage();
}

Downloading a file from Amazon Simple Storage Service (S3):

Aws::S3::S3Client s3Client;
GetObjectRequest getObjectRequest;
getObjectRequest.SetBucket("sample_bucket");
getObjectRequest.SetKey("sample_key");
getObjectRequest.SetResponseStreamFactory(
    [](){
        return Aws::New(ALLOCATION_TAG, DOWNLOADED_FILENAME, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
    });
auto getObjectOutcome = s3Client.GetObject(getObjectRequest);
if(getObjectOutcome.IsSuccess())
{
    std::cout << "File downloaded from S3 to location " << DOWNLOADED_FILENAME;
}
else
{
    std::cout << "File download failed from s3 with error " << getObjectOutcome.GetError().GetMessage();
}

It’s that simple! Download the code from GitHub today and start scaling your C++ applications with the power of Amazon Web Services.

Status
We are launching the AWS SDK for C++ in its current experimental state while we gather feedback from users and the open source community to harden the APIs. We also are adding support for individual services as we become more confident that the client generator can properly support each protocol. Support for more services will be coming in the near future. We invite our customers to follow along with our progress and join the development efforts by submitting pull requests and sending us feedback and ideas via GitHub Issues.

Jonathan Henson, Software Development Engineer (SDE)