From 6268101e5487c74c4d38d427f63e8e237bb7e464 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Wed, 17 Jul 2024 13:11:56 -0400 Subject: [PATCH] Added note on anonymous credentials usage for GetBucketRegion Signed-off-by: Tiger Kaovilai --- feature/s3/manager/bucket_region.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/feature/s3/manager/bucket_region.go b/feature/s3/manager/bucket_region.go index 22615ac0eda..14cc7281ee8 100644 --- a/feature/s3/manager/bucket_region.go +++ b/feature/s3/manager/bucket_region.go @@ -17,7 +17,7 @@ const bucketRegionHeader = "X-Amz-Bucket-Region" // GetBucketRegion will attempt to get the region for a bucket using the // client's configured region to determine which AWS partition to perform the query on. // -// The request will not be signed, and will not use your AWS credentials. +// The request will not be signed. // // A BucketNotFound error will be returned if the bucket does not exist in the // AWS partition the client region belongs to. @@ -60,6 +60,14 @@ const bucketRegionHeader = "X-Amz-Bucket-Region" // if err != nil { // panic(err) // } +// +// If buckets are public, you may use anonymous credential like so. +// manager.GetBucketRegion(ctx, s3.NewFromConfig(cfg), bucket, func(o *s3.Options) { +// o.Credentials = nil +// // Or +// o.Credentials = aws.AnonymousCredentials{} +// }) +// Otherwise credentials would be required for private buckets. func GetBucketRegion(ctx context.Context, client HeadBucketAPIClient, bucket string, optFns ...func(*s3.Options)) (string, error) { var captureBucketRegion deserializeBucketRegion