getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.
http://docs.getmoto.org/en/latest/
Apache License 2.0
7.58k stars 2.02k forks source link

S3 get_bucket_location returns us-east-1 rather than None #1959

Closed gbataille closed 5 years ago

gbataille commented 5 years ago

In AWS, us-east-1 is the default region and as such, things behave a little bit differently there:

In [9]: s3_cli.get_bucket_location(Bucket='pix4d-development-us-east-1-assets-drop-zone')
Out[9]:
{'ResponseMetadata': {'RequestId': 'D6CC81F0D293872E',
  'HostId': 'LCf3LHvjW0lpzZ81YTsZYdU33hwqr3HeBm8pDvxEUArDwEZwA/zY38L84S9u8isM8bO3UcXH9H0=',
  'HTTPStatusCode': 200,
  'HTTPHeaders': {'x-amz-id-2': 'LCf3LHvjW0lpzZ81YTsZYdU33hwqr3HeBm8pDvxEUArDwEZwA/zY38L84S9u8isM8bO3UcXH9H0=',
   'x-amz-request-id': 'D6CC81F0D293872E',
   'date': 'Tue, 20 Nov 2018 07:17:41 GMT',
   'content-type': 'application/xml',
   'transfer-encoding': 'chunked',
   'server': 'AmazonS3'},
  'RetryAttempts': 0},
 'LocationConstraint': None}
In [7]: s3_cli.create_bucket(Bucket='pix4d-test-gba2', CreateBucketConfiguration={'LocationConstraint': 'us-east-1'})
...
ClientError: An error occurred (InvalidLocationConstraint) when calling the CreateBucket operation: The specified location-constraint is not valid

(this issue is somewhat related to #971)

gbataille commented 5 years ago

I might take a crack at fixing it later today (no promises though :( )