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 © 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 Maintenance and support for SDK major versions .......................................................................... 1 Getting started .................................................................................................................................. 2 Providing AWS credentials .......................................................................................................... 2 Create an AWS account and administrator user ...................................................................... 2 Create AWS credentials and a profile .................................................................................... 3 More information on user credentials ................................................................................... 3 Getting the SDK from source ....................................................................................................... 4 Build on Windows .............................................................................................................. 4 Build on Linux/macOS ........................................................................................................ 6 "Hello S3" app .................................................................................................................. 8 Getting the SDK from a package manager ................................................................................... 12 Getting the SDK using vcpkg ............................................................................................. 12 Getting the SDK using NuGet (deprecated) .......................................................................... 12 Build on Windows ............................................................................................................ 12 Build on Linux/macOS ...................................................................................................... 14 "Hello S3" app ................................................................................................................ 15 Troubleshooting build issues ...................................................................................................... 17 CMake Error: Could not find a package configuration file provided by "AWSSDK" ....................... 17 CMake Error: Could not find load file (and you're on SDK version 1.8) ...................................... 17 CMake Error: Could not find load file .................................................................................. 18 Runtime Error: cannot proceed because aws-*.dll was not found ........................................ 18 Configuring the SDK ......................................................................................................................... 20 CMake parameters ................................................................................................................... 20 General CMake Variables and Options ................................................................................. 20 Android CMake Variables and Options ................................................................................ 24 Overriding Your HTTP Client ..................................................................................................... 26 Controlling iostreams used by the HttpClient and the AWSClient ................................................... 26 Using the SDK ................................................................................................................................. 27 Basic Use ............................................................................................................................... 27 Initializing and Shutting Down the SDK ............................................................................... 27 Setting SDK Options ......................................................................................................... 28 AWS Client configuration ......................................................................................................... 28 Configuration Variables ..................................................................................................... 29 Service Client Classes ............................................................................................................... 31 Utility Modules ........................................................................................................................ 31 HTTP Stack ...................................................................................................................... 31 String Utils ...................................................................................................................... 32 Hashing Utils ................................................................................................................... 32 JSON Parser .................................................................................................................... 32 XML Parser ...................................................................................................................... 32 Memory Management ............................................................................................................... 32 Allocating and Deallocating Memory .................................................................................. 33 STL and AWS Strings and Vectors ...................................................................................... 33 Remaining Issues .............................................................................................................. 34 Native SDK Developers and Memory Controls ...................................................................... 34 Logging ................................................................................................................................... 35 Error Handling ......................................................................................................................... 36 SDK Metrics ............................................................................................................................ 37 Enable SDK Metrics for the AWS SDK for C++ ...................................................................... 38 Update a CloudWatch Agent .............................................................................................. 38 Disable SDK Metrics .......................................................................................................... 39 Definitions for SDK Metrics ................................................................................................ 40 iii AWS SDK for C++ Developer Guide Code examples ................................................................................................................................. 42 Getting started on code examples .............................................................................................. 42 Structure of the code examples ......................................................................................... 42 Amazon CloudWatch examples .................................................................................................. 43 Getting Metrics from CloudWatch ..................................................................................... 44 Publishing Custom Metric Data ......................................................................................... 45 Working with CloudWatch Alarms ..................................................................................... 47 Using Alarm Actions in CloudWatch ................................................................................... 50 Sending Events to CloudWatch ......................................................................................... 52 Amazon DynamoDB examples .................................................................................................... 54 Working with Tables in DynamoDB .................................................................................... 54 Working with Items in DynamoDB ..................................................................................... 60 Amazon EC2 examples .............................................................................................................. 63 Managing Amazon EC2 Instances ...................................................................................... 63 Using Elastic IP Addresses in Amazon EC2 .......................................................................... 70 Using Regions and Availability Zones for Amazon EC2 .........................................................