The specified location-constraint is not valid : S3 bucket in US-East-1
See original GitHub issueHi I’m trying to create bucket in us-east-1
region and the sdk seemed to behave weirdly.
When you don’t select any region as per follow code it by default creates bucket in North Virginia region
const AWS = require('aws-sdk');
const s3 = new AWS.S3({ signatureVersion: 'v4' });
var params = {
Bucket: 'aws-bucket-101',
};
s3.createBucket(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
But if you add LocationConstraint
in params as per following
var params = {
Bucket: 'aws-bucket-101',
CreateBucketConfiguration: {
LocationConstraint: 'us-east-1'
}
};
you get this error
InvalidLocationConstraint: The specified location-constraint is not valid
at Request.extractError (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\services\s3.js:700:35)
at Request.callListeners (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
at Request.emit (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
at Request.emit (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\request.js:688:14)
at Request.transition (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\state_machine.js:14:12)
at C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request.<anonymous> (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\request.js:38:9)
at Request.<anonymous> (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\request.js:690:12)
at Request.callListeners (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\sequential_executor.js:116:18) {
code: 'InvalidLocationConstraint',
region: null,
time: 2021-02-23T17:50:24.428Z,
requestId: 'CCCF238B61F7DE69',
extendedRequestId: 'gQjXGp4YoXGh3IAiG5HCARzQTLYv0J1QOQn/PFHhyjH8UBvxEYcfn/5MBRQwnLI66RTm4fVlsMs=',
cfId: undefined,
statusCode: 400,
retryable: false,
retryDelay: 65.88958024936602
} InvalidLocationConstraint: The specified location-constraint is not valid
at Request.extractError (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\services\s3.js:700:35)
at Request.callListeners (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
at Request.emit (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
at Request.emit (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\request.js:688:14)
at Request.transition (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\state_machine.js:14:12)
at C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request.<anonymous> (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\request.js:38:9)
at Request.<anonymous> (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\request.js:690:12)
at Request.callListeners (C:\Users\Rahul\Desktop\Image-upload-S3-dynamoDB\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
However it doesn’t give this error if you try to create bucket in other region. So, Please fix this inconsistency
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
InvalidLocationConstraint error while creating S3 bucket when ...
An error occurred (InvalidLocationConstraint) when calling the CreateBucket operation: The specified location-constraint is not valid when using ...
Read more >Amazon S3's PUT Bucket API cannot accept “us-east-1” region
“Amazon S3's PUT Bucket API cannot accept “us-east-1” region” is published by ... They say “The specified location-constraint is not valid”.
Read more >IllegalLocationConstraintException error when using s3 ...
In aws cloud9 I run the code import boto3 s3 = boto3.client('s3') s3.create_bucket(Bucket='cst-my-bucket') and get the error message: Traceback (most recent ...
Read more >AWS S3 Error – InvalidLocationConstraint – “The specified ...
This error is returned when trying to create a S3 bucket using the ... < Message >The specified location-constraint is not valid</ Message...
Read more >GetBucketLocation - Amazon Simple Storage Service
For a list of all the Amazon S3 supported location constraints by Region, see Regions and Endpoints. Buckets in Region us-east-1 have a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
for most cases I think it doesn’t save code rather add, because we would need to add an if condition to not set it if the region is us-east-1
@ajredniwja I think you should give options to dev. It just makes the experience consistent. In my opinion you’ll be just saving few lines of code which have nil effect on performance