AWS SDK for C++ Developer Guide
Total Page:16
File Type:pdf, Size:1020Kb
AWS SDK for C++ Developer Guide AWS SDK for C++: Developer Guide Copyright © 2020 Amazon Web Services, Inc. and/or its affiliates. All rights reserved. AWS SDK for C++ Developer 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 SDK for C++ Developer Guide Table of Contents AWS SDK for C++ Developer Guide ..................................................................................................... 1 Additional Documentation and Resources ...................................................................................... 1 Getting Started .................................................................................................................................. 2 Setting Up the AWS SDK for C++ ................................................................................................ 2 Prerequisites ...................................................................................................................... 2 Getting the SDK Using NuGet with Visual C++ ....................................................................... 3 Getting the SDK Using Vcpkg with Visual C++ ........................................................................ 3 Building the SDK from Source ............................................................................................. 4 Providing AWS Credentials ......................................................................................................... 6 Using the AWS SDK for C++ ....................................................................................................... 6 Initializing and Shutting Down the SDK ................................................................................ 7 Setting SDK Options ........................................................................................................... 7 More Information ............................................................................................................... 8 Building Your Application with CMake ......................................................................................... 8 Setting Up a CMake Project ................................................................................................. 8 Setting CMAKE_PREFIX_PATH (Optional) ............................................................................... 9 Building with CMake ........................................................................................................... 9 Configuring the SDK ......................................................................................................................... 10 CMake Parameters ................................................................................................................... 10 General CMake Variables and Options ................................................................................. 10 Android CMake Variables and Options ................................................................................ 14 AWS Client Configuration ......................................................................................................... 16 Configuration Variables ..................................................................................................... 16 Overriding Your HTTP Client ..................................................................................................... 18 Controlling IOStreams Used by the HttpClient and the AWSClient .................................................. 18 SDK Metrics ............................................................................................................................ 19 Enable SDK Metrics for the AWS SDK for C++ ...................................................................... 19 Update a CloudWatch Agent .............................................................................................. 20 Disable SDK Metrics .......................................................................................................... 21 Definitions for SDK Metrics ................................................................................................ 21 Using the SDK ................................................................................................................................. 23 Service Client Classes ............................................................................................................... 23 Utility Modules ........................................................................................................................ 23 HTTP Stack ...................................................................................................................... 23 String Utils ...................................................................................................................... 23 Hashing Utils ................................................................................................................... 24 JSON Parser .................................................................................................................... 24 XML Parser ...................................................................................................................... 24 Memory Management ............................................................................................................... 24 Allocating and Deallocating Memory .................................................................................. 24 STL and AWS Strings and Vectors ...................................................................................... 25 Remaining Issues .............................................................................................................. 26 Native SDK Developers and Memory Controls ...................................................................... 26 Logging ................................................................................................................................... 27 Error Handling ......................................................................................................................... 27 Code Examples ................................................................................................................................ 29 Amazon CloudWatch Examples .................................................................................................. 29 Getting Metrics from CloudWatch ..................................................................................... 30 Publishing Custom Metric Data ......................................................................................... 31 Working with CloudWatch Alarms ..................................................................................... 32 Using Alarm Actions in CloudWatch ................................................................................... 35 Sending Events to CloudWatch ......................................................................................... 37 Amazon DynamoDB Examples .................................................................................................... 40 Working with Tables in DynamoDB .................................................................................... 40 iii AWS SDK for C++ Developer Guide Working with Items in DynamoDB ..................................................................................... 45 Amazon EC2 Examples .............................................................................................................. 48 Managing Amazon EC2 Instances ...................................................................................... 49 Using Elastic IP Addresses in Amazon EC2 .......................................................................... 55 Using Regions and Availability Zones for Amazon EC2 .......................................................... 58 Working with Amazon EC2 Key Pairs ................................................................................. 60 Working with Security Groups in Amazon EC2 ..................................................................... 62 AWS Identity and Access Management (IAM) Examples .................................................................. 65 Managing IAM Access Keys ............................................................................................... 66 Managing IAM Users ........................................................................................................ 70 Using IAM Account Aliases ................................................................................................ 73 Working with IAM Policies ................................................................................................ 76 Working with IAM Server Certificates ................................................................................. 81 Amazon S3 Examples ................................................................................................................ 85 Creating, Listing, and Deleting Buckets .............................................................................. 85 Operations on Objects ....................................................................................................