Skip to content

China S3 bucket resource returning 401 for non-ICP accounts #42743

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

Closed
adobe-jeremy opened this issue May 23, 2025 · 3 comments · Fixed by #42786
Closed

China S3 bucket resource returning 401 for non-ICP accounts #42743

adobe-jeremy opened this issue May 23, 2025 · 3 comments · Fixed by #42786
Labels
bug Addresses a defect in current functionality. partition/aws-cn Pertains to the aws-cn partition. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/s3 Issues and PRs that pertain to the s3 service.
Milestone

Comments

@adobe-jeremy
Copy link

adobe-jeremy commented May 23, 2025

Terraform and AWS Provider Version

Terraform v1.7.3
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.98.0

Affected Resource(s) or Data Source(s)

  • aws_s3_bucket

Expected Behavior

Terrraform bucket created and both plan and apply finish successfully.

Actual Behavior

Terraform plan is successful. During apply the bucket is created but the apply ultimately fails with an error.

Relevant Error/Panic Output

 Error: reading S3 Bucket (my-tf-test-bucket-10000) location: operation error S3: HeadBucket, https response error StatusCode: 401, RequestID: V2D8C443RGNNEDZ6, HostID: d6tTm73+CHIR3BhZwA6WIonZs3TB0zYI35gQaWNQgQJuPu2F72TKzXXpMv/tTr2Y4pqLyJPo8OA=, api error Unauthorized: Unauthorized

│   with aws_s3_bucket.d,
│   on main.tf line 17, in resource "aws_s3_bucket" "d":
│   17: resource "aws_s3_bucket" "d" {

Sample Terraform Configuration

terraform {
    required_version = ">= 1.0"

    required_providers {
        aws = {
            source  = "hashicorp/aws"
            version = "5.98.0"
        }
    }
}

provider "aws" {
  region = "cn-north-1"
}


resource "aws_s3_bucket" "d" {
  bucket = "my-tf-test-bucket-10000"
}

Steps to Reproduce

  1. Terraform apply

Debug Logging

Click to expand log output
2025-05-23T09:57:10.855-0400 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2025-05-23T09:57:10.860-0400 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2025-05-23T09:57:10.860-0400 [ERROR] vertex "aws_s3_bucket.d" error: reading S3 Bucket (my-tf-test-bucket-10000) location: operation error S3: HeadBucket, https response error StatusCode: 401, RequestID: V2D8C443RGNNEDZ6, HostID: d6tTm73+CHIR3BhZwA6WIonZs3TB0zYI35gQaWNQgQJuPu2F72TKzXXpMv/tTr2Y4pqLyJPo8OA=, api error Unauthorized: Unauthorized
2025-05-23T09:57:10.860-0400 [TRACE] vertex "aws_s3_bucket.d": visit complete, with errors
2025-05-23T09:57:10.860-0400 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" errored, so skipping
2025-05-23T09:57:10.860-0400 [TRACE] dag/walk: upstream of "root" errored, so skipping
2025-05-23T09:57:10.860-0400 [TRACE] statemgr.Filesystem: reading latest snapshot from terraform.tfstate
2025-05-23T09:57:10.860-0400 [TRACE] statemgr.Filesystem: read snapshot with lineage "25d3357c-3547-6c8a-f959-455fa4048f8e" serial 1
2025-05-23T09:57:10.860-0400 [TRACE] statemgr.Filesystem: no original state snapshot to back up
2025-05-23T09:57:10.860-0400 [TRACE] statemgr.Filesystem: no state changes since last snapshot
2025-05-23T09:57:10.860-0400 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate

│ Error: reading S3 Bucket (my-tf-test-bucket-10000) location: operation error S3: HeadBucket, https response error StatusCode: 401, RequestID: V2D8C443RGNNEDZ6, HostID: d6tTm73+CHIR3BhZwA6WIonZs3TB0zYI35gQaWNQgQJuPu2F72TKzXXpMv/tTr2Y4pqLyJPo8OA=, api error Unauthorized: Unauthorized

│   with aws_s3_bucket.d,
│   on main.tf line 17, in resource "aws_s3_bucket" "d":
│   17: resource "aws_s3_bucket" "d" {


2025-05-23T09:57:10.867-0400 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2025-05-23T09:57:10.867-0400 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2025-05-23T09:57:10.868-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-05-23T09:57:10.871-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.98.0/darwin_arm64/terraform-provider-aws_v5.98.0_x5 pid=48537
2025-05-23T09:57:10.871-0400 [DEBUG] provider: plugin exited

GenAI / LLM Assisted Development

n/a

Important Facts and References

This looks to me to be a regression or at least similar to #15420. Additionally, the issue does not occur in provider version v5.97.0, so it looks to be introduced in v5.98.0. I suspect that the underlying cause is the upgrade of github.com/aws/aws-sdk-go-v2/feature/s3/manager to v1.17.75 due to https://github.com/aws/aws-sdk-go-v2/pull/3081/files

Would you like to implement a fix?

No

@adobe-jeremy adobe-jeremy added the bug Addresses a defect in current functionality. label May 23, 2025
Copy link

Community Guidelines

This comment is added to every new Issue to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Issue and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/s3 Issues and PRs that pertain to the s3 service. labels May 23, 2025
@ewbankkit ewbankkit added partition/aws-cn Pertains to the aws-cn partition. and removed needs-triage Waiting for first response or review from a maintainer. labels May 27, 2025
@ewbankkit
Copy link
Contributor

Relates #42739.

@ewbankkit ewbankkit added the regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. label May 27, 2025
@github-actions github-actions bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label May 27, 2025
Copy link

Warning

This Issue has been closed, meaning that any additional comments are much easier for the maintainers to miss. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.99.0 milestone May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. partition/aws-cn Pertains to the aws-cn partition. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/s3 Issues and PRs that pertain to the s3 service.
Projects
None yet
2 participants