s3: fix S3 Object Lock header issue for lock file writes #36120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #36113
When S3 Object Lock is enabled on a bucket with a retention period, Amazon S3 requires the
Content-MD5
orx-amz-sdk-checksum-algorithm
header to be present in object uploads (PutObject). See Uploading objects to an Object Lock enabled bucket.It seems we overlooked maintaining the default behavior of the
skip_checksum
flag for the lock file when writing to S3 Object Lock-enabled buckets.To clarify the default behavior of
skip_checksum
: by default, if this argument is not set in the backend, we set the S3 checksum algorithm behavior toSHA256
. This causes the underlying S3 AWS SDK V2 serializers to automatically append that requiredx-amz-sdk-checksum-algorithm
header. For more details, see the relevant code in the AWS SDK v2 serializers.This PR updates the lock file implementation to use the same "uploader" that we rely on for writing Terraform state to S3, and preserving the default
skip_checksum
behavior for the lock file. To ensure a consistent and compatible experience with S3 Object Lock-enabled buckets between the two mechanisms writing data to S3.