For anyone who may be encountering the same problem, the solution was simple:
Set your region
parameter for Aws::S3::S3Client
to containg smart
in the end, e.g. us-south-smart
.
Set the location constraint using Aws::S3::Model::BucketLocationConstraintMapper
to match the region
.
Corrected code:
Aws::S3::Model::CreateBucketRequest request; request.SetBucket(bucket); Aws::S3::Model::CreateBucketConfiguration bucketConfig; bucketConfig.SetLocationConstraint(Aws::S3::Model::BucketLocationConstraintMapper::GetBucketLocationConstraintForName(region));//this is the key request.SetCreateBucketConfiguration(bucketConfig); const auto crtOutcome = client.CreateBucket(request); if (crtOutcome.IsSuccess()) { std::cout << "created bucket" << std::endl; }else { std::cout << crtOutcome.GetError().GetMessage() << std::endl; }