Hi,
I have say three buckets in my AWS account.
When I run the below command
aws s3api get-bucket-location --bucket <my_bucket_name>
I get
{
"LocationConstraint": null
}
On checking the same bucket in AWS Console, the bucket region is US East (N. Virginia)
@abhishekbedi1432 - Thank you for reaching out. The location constraint will be null
for buckets located in US Standard region. The CLI uses the values in the region
column for the --region
parameter. So for S3's US Standard, you need to use us-east-1
as the region. When working with this bucket you'll need to use:
aws s3api get-bucket-location --bucket <my_bucket_name> --region us-east-1
The following documentation provides a list of region names with their corresponding regions: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region. If this does not answer your question, please reply with the sanitized output from using --debug
so I can dig a little deeper into the problem.
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.
For future reference if one need to retrieve the region of the bucket(which seems to be the case when using get-bucket-location
, one can use jq
to set the region by default:
aws s3api get-bucket-location --bucket "<my_bucket_name>" \
| jq -r '.LocationConstraint // "us-east-1"'
Or directly the query option(using JMESPath):
aws s3api get-bucket-location \
--bucket "<my_bucket_name>" \
--query="[?LocationConstraint]|'us-east-1'" \
--output=text
Beware that the double quotes are required for the query to work.
Most helpful comment
For future reference if one need to retrieve the region of the bucket(which seems to be the case when using
get-bucket-location
, one can usejq
to set the region by default:Or directly the query option(using JMESPath):
Beware that the double quotes are required for the query to work.