Skip to content
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

Use the current credentials when trying to get the bucket region #15481

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions aws/data_source_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func bucketLocation(client *AWSClient, d *schema.ResourceData, bucket string) er
// the provider s3_force_path_style configuration, which defaults to
// false, but allows override.
r.Config.S3ForcePathStyle = client.s3conn.Config.S3ForcePathStyle

// By default, GetBucketRegion uses anonymous credentials when doing
// a HEAD request to get the bucket region. This breaks in aws-cn regions
// when the account doesn't have an ICP license to host public content.
// Use the current credentials when getting the bucket region.
r.Config.Credentials = client.s3conn.Config.Credentials
})
if err != nil {
return err
Expand Down
6 changes: 6 additions & 0 deletions aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,12 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
// the provider s3_force_path_style configuration, which defaults to
// false, but allows override.
r.Config.S3ForcePathStyle = s3conn.Config.S3ForcePathStyle

// By default, GetBucketRegion uses anonymous credentials when doing
// a HEAD request to get the bucket region. This breaks in aws-cn regions
// when the account doesn't have an ICP license to host public content.
// Use the current credentials when getting the bucket region.
r.Config.Credentials = s3conn.Config.Credentials
})
})
if err != nil {
Expand Down