Support creating S3 caches in other regions than us-east-1

This commit is contained in:
Eelco Dolstra 2017-06-19 18:39:57 +02:00
parent b33621d425
commit 82a0d614cf
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -187,14 +187,20 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
if (res.GetError().GetErrorType() != Aws::S3::S3Errors::NO_SUCH_BUCKET) if (res.GetError().GetErrorType() != Aws::S3::S3Errors::NO_SUCH_BUCKET)
throw Error(format("AWS error checking bucket %s: %s") % bucketName % res.GetError().GetMessage()); throw Error(format("AWS error checking bucket %s: %s") % bucketName % res.GetError().GetMessage());
printInfo("creating S3 bucket %s...", bucketName);
// Stupid S3 bucket locations.
auto bucketConfig = Aws::S3::Model::CreateBucketConfiguration();
if (s3Helper.config->region != "us-east-1")
bucketConfig.SetLocationConstraint(
Aws::S3::Model::BucketLocationConstraintMapper::GetBucketLocationConstraintForName(
s3Helper.config->region));
checkAws(format("AWS error creating bucket %s") % bucketName, checkAws(format("AWS error creating bucket %s") % bucketName,
s3Helper.client->CreateBucket( s3Helper.client->CreateBucket(
Aws::S3::Model::CreateBucketRequest() Aws::S3::Model::CreateBucketRequest()
.WithBucket(bucketName) .WithBucket(bucketName)
.WithCreateBucketConfiguration( .WithCreateBucketConfiguration(bucketConfig)));
Aws::S3::Model::CreateBucketConfiguration()
/* .WithLocationConstraint(
Aws::S3::Model::BucketLocationConstraint::US) */ )));
} }
BinaryCacheStore::init(); BinaryCacheStore::init();