Repository navigation
Use dualstack and FIPS endpoint env var and AWS config file settings are ignored #3966
Description
Describe the bug
This may just be a documentation issue where the C++ SDK is erroneously listed, but having parity across all of the SDKs seems like the better solution, so I'm filing this as a bug.
https://docs.aws.amazon.com/sdkref/latest/guide/feature-endpoints.html states that the SDK for C++ supports the use dualstack and FIPS endpoint env vars and config file settings.
I examined the code and tested it out, and the only way to use the dualstack endpoint was to explicitly set it in the client constructor. Otherwise useDualStack = false is set in all constructors via https://github.com/aws/aws-sdk-cpp/blob/1.11.760/src/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp#L210.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
Setting an env var like AWS_USE_DUALSTACK_ENDPOINT results in the endpoint s3.dualstack.<aws-region>.amazonaws.com being used, not s3.<aws-region>.amazonaws.com
Current Behavior
The environment variable isn't respected and the code client config sets useDualStack = false and uses the non-dualstack endpoint (s3.<aws-region>.amazonaws.com)
Reproduction Steps
#include <aws/core/Aws.h>
#include <aws/core/VersionConfig.h>
#include <aws/s3/S3ClientConfiguration.h>
#include <aws/s3/S3EndpointProvider.h>
#include <iostream>
static void printResolvedEndpoint(const char* label, const Aws::S3::S3ClientConfiguration& config) {
Aws::S3::Endpoint::S3EndpointProvider provider;
provider.InitBuiltInParameters(config);
Aws::Endpoint::EndpointParameters params;
params.emplace_back("Bucket", "amzn-s3-demo-bucket");
const auto outcome = provider.ResolveEndpoint(params);
std::cout << label << ": useDualStack=" << std::boolalpha << config.useDualStack << " endpoint="
<< (outcome.IsSuccess() ? outcome.GetResult().GetURL() : outcome.GetError().GetMessage()) << std::endl;
}
int main() {
Aws::SDKOptions options;
Aws::InitAPI(options);
{
std::cout << "SDK " << AWS_SDK_VERSION_STRING << std::endl;
Aws::S3::S3ClientConfiguration config;
config.region = "us-east-1";
printResolvedEndpoint("default-constructed", config);
config.useDualStack = true;
printResolvedEndpoint("useDualStack set in code", config);
}
Aws::ShutdownAPI(options);
return 0;
}
$ AWS_USE_DUALSTACK_ENDPOINT=true AWS_EC2_METADATA_DISABLED=true ./repro
SDK 1.11.760
default-constructed: useDualStack=false endpoint=https://amzn-s3-demo-bucket.s3.us-east-1.amazonaws.com
useDualStack set in code: useDualStack=true endpoint=https://amzn-s3-demo-bucket.s3.dualstack.us-east-1.amazonaws.com
Possible Solution
Suggested fix: load both settings in setConfigFromEnvOrProfile, or update the docs row to say No that the SDK for C++ does not support it.
Additional Information/Context
I tested on SDK version 1.11.760 because that's what my app currently uses, but the issue is still present in the current main code.
AWS CPP SDK version used
1.11.760
Compiler and Version used
g++ (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
Operating System and version
Ubuntu 22.04.5 LTS (kernel 6.8.0-1063-aws)
Activity