aws / aws/aws-cli

Add `s3` command to get bucket region

Open
#8,063 7 comments 0 reactions 0 assignees View on GitHub
feature-request p2 s3
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the bug

The recommended way to get the region in which S3 bucket is located is the HeadBucket call. But the region is specified in the HTTP headers of the response.

Follow up for #244, which is for `head-object`, but there is the `head-bucket` also, and there is no strict way to get bucket region via aws-cli currently.

### Expected Behavior

There should be an easy, clear and documented way to get the bucket region from `aws s3api head-bucket` call.

### Current Behavior

Currently, the only way to get s3 bucket region is to look for the response headers using the `--debug` flag.

### Reproduction Steps

1. See that this command provides empty output:
```
aws s3api head-bucket --bucket commoncrawl
```

2. Try to find how to get s3 bucket region.

### Possible Solution

* make `head-bucket` return headers as it is for `head-object`
* special command in `aws s3` group
* make `--query` flag to be able to access response headers (or add a similar flag like `--query-headers`), and add example in docs how to use it to get bucket region

### Additional Information/Context

_No response_

### CLI version used

aws-cli/2.13.1

### Environment details (OS name and version, etc.)

Python/3.11.3 Linux/6.4.5-arch1-1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.