I'm trying to use the AWS C++ SDK to generate a signed URL for S3, however the Aws::S3::S3Client
constructor seems very slow. In the following example:
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
int main() {
Aws::SDKOptions options;
Aws::InitAPI(options);
printf("1\n");
Aws::S3::S3Client client;
printf("2\n");
Aws::ShutdownAPI(options);
}
compiled with:
g++ example.cc -laws-cpp-sdk-core -laws-cpp-sdk-s3
there is long delay (at least 5 seconds) between 1
and 2
. What is causing this?
The library was built and installed with:
git clone https://github.com/aws/aws-sdk-cpp.git
cd aws-sdk-cpp
cmake . -DCMAKE_BUILD_TYPE=Release -D BUILD_ONLY="s3"
make
make install
When not running on AWS, set:
AWS_EC2_METADATA_DISABLED=true
to disable the metadata API which is what's causing the delay.