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

Conversation

ebabani
Copy link
Contributor

@ebabani ebabani commented Oct 5, 2020

This fixes #15420 where in aws-cn using anonymous credentials will cause the Head request to return Unauthorized. That error in turn fill cause terraform bucket operations to fail.

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #15420

Release note for CHANGELOG:

resource/aws_s3_bucket: Use current provider credentials when fetching the bucket region

Output from acceptance testing in AWS Commercial:

$ make testacc TESTARGS='-run= TestAccAWSS3Bucket_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSS3Bucket_basic -timeout 120m
=== RUN   TestAccAWSS3Bucket_basic
=== PAUSE TestAccAWSS3Bucket_basic
=== CONT  TestAccAWSS3Bucket_basic
--- PASS: TestAccAWSS3Bucket_basic (63.20s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	65.843s
...

Acceptance tests fail in aws-cn due to a separate issue (resource_aws_s3_bucket_test.go:170: Check 2/8 error: aws_s3_bucket.bucket: Attribute 'hosted_zone_id' not found) but have verified the fix manually.

This fixes hashicorp#15420 where in aws-cn using anonymous credentials will cause the Head request to return Unauthorized. That error in turn fill cause terraform bucket operations to fail.
@ebabani ebabani requested a review from a team October 5, 2020 12:20
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/s3 Issues and PRs that pertain to the s3 service. labels Oct 5, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 5, 2020
@ebabani
Copy link
Contributor Author

ebabani commented Oct 12, 2020

Hi,

Anything else that needs to be done before this is reviewed? At the moment this bug blocks s3 bucket creates/updates for accounts in aws-cn which don't have ICP configured.

In our use case that is every account created through AWS Organizations.

@damoco
Copy link

damoco commented Oct 19, 2020

When will this request can be merged in?

@all4innov
Copy link

Any timeline when this PR will be merged ?

@ebabani
Copy link
Contributor Author

ebabani commented Oct 29, 2020

Hi. Any updates on this PR? As it stands terraform s3 operations in a large subset of aws-cn accounts will always fail.

@yogeek
Copy link

yogeek commented Nov 13, 2020

Our team currently have to use the code of this PR to deploy poduction infrastructure in China so we can confirm this code is solving the issue. Thanks again @ebabani 👍

But until this is merged, we have to recompile the provider and override the default one by the patched one...not really ideal for an automated process !
Can someone take a look and merge please ? Thank you :-)

@ybulakhau
Copy link

Hi, guys. We also cannot continue to work in China until these changes are merged. Please merged it.

@dawidmalina
Copy link

We are also blocked by this issue :(

@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 17, 2020
@bflad bflad added this to the v3.16.0 milestone Nov 17, 2020
@bflad bflad added the partition/aws-cn Pertains to the aws-cn partition. label Nov 17, 2020
@bflad bflad linked an issue Nov 17, 2020 that may be closed by this pull request
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you for this update, @ebabani 🚀

Output from acceptance testing:

--- PASS: TestAccAWSS3Bucket_acceleration (96.61s)
--- PASS: TestAccAWSS3Bucket_AclToGrant (91.15s)
--- PASS: TestAccAWSS3Bucket_basic (58.12s)
--- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (57.42s)
--- PASS: TestAccAWSS3Bucket_Cors_Delete (48.59s)
--- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (58.18s)
--- PASS: TestAccAWSS3Bucket_Cors_Update (99.78s)
--- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (97.18s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (58.48s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (59.64s)
--- PASS: TestAccAWSS3Bucket_forceDestroy (42.93s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (40.26s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (37.51s)
--- PASS: TestAccAWSS3Bucket_generatedName (56.37s)
--- PASS: TestAccAWSS3Bucket_GrantToAcl (96.56s)
--- PASS: TestAccAWSS3Bucket_ignoreTags (92.12s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (117.55s)
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (95.88s)
--- PASS: TestAccAWSS3Bucket_LifecycleRule_AbortIncompleteMultipartUploadDays_NoExpiration (59.40s)
--- PASS: TestAccAWSS3Bucket_LifecycleRule_Expiration_EmptyConfigurationBlock (50.49s)
--- PASS: TestAccAWSS3Bucket_Logging (57.51s)
--- PASS: TestAccAWSS3Bucket_namePrefix (54.99s)
--- PASS: TestAccAWSS3Bucket_objectLock (63.40s)
--- PASS: TestAccAWSS3Bucket_Policy (142.88s)
--- PASS: TestAccAWSS3Bucket_Replication (164.69s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (117.29s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AddAccessControlTranslation (110.12s)
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (45.30s)
--- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (142.38s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (72.68s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutStorageClass (79.07s)
--- PASS: TestAccAWSS3Bucket_RequestPayer (96.23s)
--- PASS: TestAccAWSS3Bucket_SameRegionReplicationSchemaV2 (53.21s)
--- PASS: TestAccAWSS3Bucket_shouldFailNotFound (38.56s)
--- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (181.24s)
--- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (228.92s)
--- PASS: TestAccAWSS3Bucket_UpdateAcl (100.08s)
--- PASS: TestAccAWSS3Bucket_UpdateGrant (147.12s)
--- PASS: TestAccAWSS3Bucket_Versioning (132.83s)
--- PASS: TestAccAWSS3Bucket_Website_Simple (138.92s)
--- PASS: TestAccAWSS3Bucket_WebsiteRedirect (142.12s)
--- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (99.74s)
--- PASS: TestAccAWSS3MultiBucket_withTags (58.18s)

--- PASS: TestAccDataSourceS3Bucket_basic (52.91s)
--- PASS: TestAccDataSourceS3Bucket_website (52.97s)

@bflad bflad merged commit 17429ae into hashicorp:master Nov 17, 2020
bflad added a commit that referenced this pull request Nov 17, 2020
@ghost
Copy link

ghost commented Nov 18, 2020

This has been released in version 3.16.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Dec 17, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. partition/aws-cn Pertains to the aws-cn partition. service/s3 Issues and PRs that pertain to the s3 service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terraform generates AccessDenied events China S3 bucket resource returning 401 for non-ICP accounts
7 participants