0
votes

I am getting a InvalidLocationConstraint: The specified location-constraint is not valid error when trying to create a S3 bucket in the af-south-1 (Cape Town) region using node.js aws-sdk, at version 2.726.0 (The latest at the time).

The region has been enabled and I am able to create a bucket using the management console. The IAM user I am using for debugging has full administrative access in the account.

My create bucket call is:

let res = await s3.createBucket({
  Bucket: 'bucketname',
  CreateBucketConfiguration: { LocationConstraint: 'af-south-1' }
}).promise();

This works for regions other than af-south-1.

In the documentation, a list of location constraints is given, is this list exhaustive of all possible options, or just a list of examples?

Is it possible to create a bucket in af-south-1 using the sdk, or am I doing something wrong?

This is similar to this question.

1

1 Answers

1
votes

Newer AWS regions only support regional endpoints. Thus, if creating buckets in more than one region, a new instance of the S3 class needs to be created for each of the regions if you are using one of the newer regions:

  const s3 = new AWS.S3({
    region: 'af-south-1',
  });