-
Notifications
You must be signed in to change notification settings - Fork 547
fix(aws): Use GetBucketLocation for S3 bucket region #10550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(aws): Use GetBucketLocation for S3 bucket region #10550
Conversation
bbernays
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good... But my only question is why did it work? If it was making unsigned calls then how was it getting the information about private buckets?
|
@bbernays If you look at the sample request in the docs, it's unsigned but still authorized: I think the real answer here is probably "S3 is a very very old API". |
|
I have a feeling that it will answer |
|
@spofdamon that's correct. golang example below to run in a Docker container without any aws config for the curious. Works for public and private buckets. package main
import (
"context"
"fmt"
"log"
"errors"
"os"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
func main() {
ctx := context.TODO()
cfg, err := config.LoadDefaultConfig(ctx,
config.WithRegion("us-west-1"),
)
if err != nil {
log.Println("error:", err)
return
}
bucket := "asdf"
region, err := manager.GetBucketRegion(ctx, s3.NewFromConfig(cfg), bucket)
if err != nil {
var bnf manager.BucketNotFound
if errors.As(err, &bnf) {
fmt.Fprintf(os.Stderr, "unable to find bucket %s's region\n", bucket)
}
return
}
fmt.Printf("Bucket %s is in %s region\n", bucket, region)
} |
🤖 I have created a release *beep* *boop* --- ## [17.2.0](plugins-source-aws-v17.1.0...plugins-source-aws-v17.2.0) (2023-05-09) ### This Release has the Following Changes to Tables - Table `aws_config_configuration_aggregators` was added - Table `aws_config_remediation_configurations` was added - Table `aws_config_retention_configurations` was added - Table `aws_networkfirewall_firewall_policies` was added - Table `aws_networkfirewall_rule_groups` was added - Table `aws_securityhub_enabled_standards` was added - Table `aws_securityhub_hubs` was added - Table `aws_wafregional_rule_groups`: column added with name `rule_ids` and type `StringArray` ### Features * **aws-services:** Support newly added regions ([#10598](#10598)) ([e56bae2](e56bae2)) * **aws:** Add `aws_securityhub_hubs` and `aws_securityhub_enabled_standards` tables ([#10553](#10553)) ([bc77f53](bc77f53)), closes [#1592](#1592) * **aws:** Add networkfirewall resources ([#10547](#10547)) ([74ada09](74ada09)) * **aws:** Add rule_ids to wafregional rule_group ([#10594](#10594)) ([4637baa](4637baa)) * **aws:** Refine AWS Org Error Message ([#10569](#10569)) ([b761ebc](b761ebc)) * More AWS Config resources ([#10509](#10509)) ([3db4ebb](3db4ebb)) ### Bug Fixes * **aws-policies:** Api Gateway xray tracing enabled query ([#10597](#10597)) ([341d849](341d849)) * **aws:** Use GetBucketLocation for S3 bucket region ([#10550](#10550)) ([7f0128f](7f0128f)), closes [#10548](#10548) * **deps:** Update module github.com/aws/aws-sdk-go-v2/config to v1.18.23 ([#10576](#10576)) ([eeb13d5](eeb13d5)) * **deps:** Update module github.com/aws/aws-sdk-go-v2/internal/v4a to v1.0.25 ([#10585](#10585)) ([00d7449](00d7449)) * **deps:** Update module github.com/aws/aws-sdk-go-v2/service/accessanalyzer to v1.19.12 ([#10586](#10586)) ([4f929fe](4f929fe)) * Remove unused line in mockassert library ([#10608](#10608)) ([3fc8708](3fc8708)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This is to prevent an s3manager unauthenticated call to get region (which then show up on CloudTrail events)
Fixes #10548