-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
China S3 bucket resource returning 401 for non-ICP accounts #15420
Comments
I'm assuming this is recent new behaviour? Getting this when updating some already existing buckets as well. |
The AWS change was made ~September 30, |
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.
It happens also in the terraform plan phase as well. As soon as terraform tries to check/evaluate the actual state of the S3 logging bucket, it raises the same error denoted above. Create the data bucketresource "aws_s3_bucket" "apr_s3_bucket" { server_side_encryption_configuration { dynamic "logging" {
} ... Create the access log bucketresource "aws_s3_bucket" "app_log_bucket" { ` |
I'm using this change to work around the issue: autonomic-ai@64e2a4f If that seems like an appropriate way to fix this I can clean it up and send a PR |
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.
Hi @ebabani ! How can we test your fix please ? |
You have to build the provider and override the AWS provider terraform uses locally. For more details see https://www.terraform.io/docs/extend/how-terraform-works.html#discovery |
@ebabani Thanks, I did that and your fix went well ! |
Hello ! Do you have an idea of a potential date to merge this fix please ? |
Might be related to #15659 |
I built the code from this PR and deployed locally overriding official AWS provider and it worked fine. |
The fix for this has been merged and will release with version 3.16.0 of the Terraform AWS Provider, later this week. Thank you to @ebabani for the implementation. 👍 |
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! |
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! |
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform 0.12.26
AWS Provider v3.5.0
Affected Resource(s)
Terraform Configuration Files
Debug Output
https://gist.github.com/michaelfoley1/06d649284ac90fe467cce2defe839ed9
Expected Behavior
Terraform should create the bucket and exit gracefully.
Actual Behavior
Terraform creates the bucket and errors out with the error message:
Error: error getting S3 Bucket location: Unauthorized: Unauthorized
Steps to Reproduce
terraform apply
Important Factoids
This only affects AWS account in the Chinese partiion that do not have ICP licenses associated to them.
If a Chinese account does have an ICP licence unauthenticated HEAD requests receive a 403 response which is gracefully handled.
It an Chinese account does not have an ICP license unauthenticated HEAD requests receive a 401 response which is not gracefully handled and errors out.
References
The text was updated successfully, but these errors were encountered: