func GetBucketRegion(ctx aws.Context, c client.ConfigProvider, bucket, regionHint string, opts ...request.Option) (string, error) {
	var cfg aws.Config
	if len(regionHint) != 0 {
		cfg.Region = aws.String(regionHint)
	}
	svc := s3.New(c, &cfg)
	return GetBucketRegionWithClient(ctx, svc, bucket, opts...)
}
GetBucketRegion will attempt to get the region for a bucket using the
regionHint to determine which AWS partition to perform the query on.

The request will not be signed, and will not use your AWS credentials.

A "NotFound" error code will be returned if the bucket does not exist in the
AWS partition the regionHint belongs to. If the regionHint parameter is an
empty string GetBucketRegion will fallback to the ConfigProvider's region
config. If the regionHint is empty, and the ConfigProvider does not have a
region value, an error will be returned..

For example to get the region of a bucket which exists in "eu-central-1"
you could provide a region hint of "us-west-2".

sess := session.Must(session.NewSession())

bucket := "my-bucket"
region, err := s3manager.GetBucketRegion(ctx, sess, bucket, "us-west-2")
if err != nil {
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "NotFound" {
fmt.Fprintf(os.Stderr, "unable to find bucket %s's region not found\n", bucket)
}
return err
}
fmt.Printf("Bucket %s is in %s region\n", bucket, region)
package s3manager
import (
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/client"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/request"
	"github.com/aws/aws-sdk-go/service/s3"
	"github.com/aws/aws-sdk-go/service/s3/s3iface"
)