Closed juancrl closed 2 years ago
Hello, Thank you for providing this feedback.
Get-S3BucketLocation
behaves according to https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETlocation.html. It returns a Location Constraint
object that can be converted to a region using the table at https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region.
I will consider this for future improvements, but it may be difficult to do so without breaking backward compatibility.I will keep this issue open and see what we can do to fix the region value returned by Get-S3BucketLocation
.
I am discovering new side effects, showing the region incoherence in multiple places. If you create a bucket from the console in eu-west-1, Get-S3BucketLocation will then show the right "LocationConstraint" (eu-west-1). But if you create it with New-S3Bucket -region "eu-west-1", Get-S3BucketLocation will just show "EU". This difference filters the bucket in other tools ! For example, when you run Glue in eu-west-1 region, it won't show you the buckets created in PowerShell ("The bucket xxxx was found in EU instead of eu-west-1. Select a bucket that was created in eu-west-1") There's a S3 client in https://www.powershellgallery.com/packages/S3-Client/1.19.0 that seems to accept or use the right location. Maybe it could be used...
From S3-Client code :
# AWS does not allow to set LocationConstraint for default region us-east-1
if ($Config.Region -ne "us-east-1") {
$RequestPayload = "<CreateBucketConfiguration xmlns=`"http://s3.amazonaws.com/doc/2006-03-01/`"><LocationConstraint>$($Config.Region)</LocationConstraint></CreateBucketConfiguration>"
}
Works like a charm... (This is important as many European users will default to eu-west-1)
We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.
In some cases, Get-S3BucketLocation -bucketname XXX returns a shorter Region Code than expected (Amazon.S3.S3Region).
In my case, I have several buckets in eu-west-1 (Ireland), Calling Get-S3BucketLocation on them returns a value of "EU", and not "EU-WEST-1".
This is a problem when using the returned region code in the next cmdlets (for example, Set-S3Object -Region...), "EU" is not accepted as a valid Region, ir expects "EU-WEST-1". The operation takes a long time and finally times out. With the valid region all is fine.
Expected behaviour 1 : Get-S3BucketLocation should always return a region code which can be used by all cmdlets 2 : All cmdlets using a Region should validate it before any traffic is attempted. 3 : Get-S3Bucket should contain the region in the object (as requested in other issue), being a property on the bucket object itself; no need to call explicitly Get-BucketLocation.
Example which fails :