Use GetBucketLocation
with an AWS SDK or CLI
The following code examples show how to use GetBucketLocation
.
- AWS CLI
-
The following command retrieves the location constraint for a bucket named
amzn-s3-demo-bucket
, if a constraint exists:aws s3api get-bucket-location --bucket
amzn-s3-demo-bucket
Output:
{ "LocationConstraint": "us-west-2" }
-
For API details, see GetBucketLocation
in AWS CLI Command Reference.
-
For a complete list of AWS SDK developer guides and code examples, see Developing with Amazon S3 using the AWS SDKs. This topic also includes information about getting started and details about previous SDK versions.