Skip to content

Terraform remote state with OCI bucket failing to save state file in OCI bucket #2348

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

Open
Calebache opened this issue Mar 31, 2025 · 6 comments
Labels
bug In-Progress Terraform Team is working on the reproduce & fix

Comments

@Calebache
Copy link

Calebache commented Mar 31, 2025

Terraform OCI Object Storage failing to save terraform remote state

terraform v1.11.3

  • provider registry.terraform.io/oracle/oci v6.32.0

Affected Resource(s)

terraform remote backend, the s3 remote state was working and suddenly stopped working with the error Error: Failed to save state. The state is initialized properly but fails to save it even with the right permission in place.

Terraform Configuration Files

terraform {
backend “s3” {
bucket = "terraform-states"
region = "us-ashburn-1"
key = "terraform-state/tf.tfstate"
access_key = ""
secret_key = ""
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
use_path_style = true
skip_s3_checksum = true
skip_metadata_api_check = true
endpoints = {
s3 = ""
}
}
}


### Debug Output

Error: Failed to save state
│
│ Error saving state: failed to upload state: operation error S3: PutObject, https response error StatusCode: 400, RequestID:
│ iad-1:0BBy1KcxkQWIHV23yOGenzbYUYqiA3EC12limtTcauUD6WSU7rAQY33U3SKlTvdy, HostID: , api error InvalidArgument: x-amz-content-sha256 must be UNSIGNED-PAYLOAD or a valid
│ sha256 value.
╵
╷
│ Error: Failed to persist state to backend
│
│ The error shown above has prevented Terraform from writing the updated state to the configured backend. To allow for recovery, the state has been written to the file
│ “errored.tfstate” in the current working directory.
│
│ Running “terraform apply” again at this point will create a forked state, making it harder to recover.
│
│ To retry writing this state, use the following command:
│     terraform state push errored.tfstate


### Expected Behavior

Terraform state should be successfully saved to OCI bucket

### Actual Behavior

Terraform is unable to save the state to OCI bucket, this was working before and recently starts popping this error affecting all my pipeline

### Steps to Reproduce

<!--- Please list the steps required to reproduce the issue. --->

1. `terraform apply`

### Important Factoids

<!--- Is there anything atypical about your environment that we should know? For example: Is the issue specific to a region? --->

### References

<!---
This issue occured last year in terraform v1.6.3 https://github.com/hashicorp/terraform/issues/34053 which is currently closed.
--->

@Calebache Calebache added the bug label Mar 31, 2025
@Calebache Calebache changed the title Trraform remote state with OCI bucket failing to save state file in OCI bucket Terraform remote state with OCI bucket failing to save state file in OCI bucket Mar 31, 2025
@tf-oci-pub tf-oci-pub added the In-Progress Terraform Team is working on the reproduce & fix label Apr 1, 2025
@tf-oci-pub
Copy link
Member

Thank you for reporting the issue. We have raised an internal ticket to track this. Our service engineers will get back to you.

@0Zusu
Copy link

0Zusu commented Apr 1, 2025

the same issue is been happening since terraform version 1.11.2, as to add further info into the issue, regards.

@Calebache
Copy link
Author

I was able to resolve this by adding these environment variables

export AWS_REQUEST_CHECKSUM_CALCULATION=when_required
export AWS_RESPONSE_CHECKSUM_VALIDATION=when_required

link to issue on hashicorp that resolved it: hashicorp/terraform#36704

@0Zusu
Copy link

0Zusu commented Apr 1, 2025

is there a way to do this through flags instead? i would have imagine that the flag "skip_s3_checksum = true" would have us skip this altogether

@dhoogfr
Copy link

dhoogfr commented Apr 1, 2025

Don't know about the configuration flags, but I found at setting the following in the ini file containing the access and secret keys works

request_checksum_calculation=when_required
response_checksum_validation=when_required

@prime4567
Copy link

prime4567 commented Apr 19, 2025

Don't know about the configuration flags, but I found at setting the following in the ini file containing the access and secret keys works

request_checksum_calculation=when_required
response_checksum_validation=when_required

I confirm that this works. The default file in Ubuntu is ~/.aws/credentials. Here is my copy"

[default]
aws_access_key_id=<your-access-key>
aws_secret_access_key=<your-secret-access-key>
request_checksum_calculation=when_required
response_checksum_validation=when_required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug In-Progress Terraform Team is working on the reproduce & fix
Projects
None yet
Development

No branches or pull requests

5 participants