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

Add test case for usage of S3 Object Lock in remote state backend #29900

Closed
wants to merge 1 commit into from

Conversation

pdecat
Copy link
Contributor

@pdecat pdecat commented Nov 8, 2021

This PR adds a test case for verifying the compatibility of S3 Object Lock with S3 remote state backend,
as #23127 reported it was not working properly.

Test results:

# TF_S3_TEST=1 go test -v ./internal/backend/remote-state/s3/ -run TestRemoteClientObjectLocks
=== RUN   TestRemoteClientObjectLocks
    client_test.go:49: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-61893862"), "encrypt":cty.True, "key":cty.StringVal("testState")}}
    backend_test.go:694: creating S3 bucket terraform-remote-s3-test-61893862 in us-west-2
    backend_test.go:739: WARNING: Failed to delete the test S3 bucket. It may have been left in your AWS account and may incur storage charges. (error was BucketNotEmpty: The bucket you tried to delete is not empty. You must delete all versions in the bucket.
                status code: 409, request id: QYT049JZMWK158C7, host id: 7FhDcdSMlLQi8Z/YSn0QrXteJVbwwTnZ5pECZH/2kQYRS5Dkk9yr1TJE/K8w6Y/Aoo86gDtToB8=)
--- PASS: TestRemoteClientObjectLocks (7.63s)
PASS
ok      github.com/hashicorp/terraform/internal/backend/remote-state/s3 7.640s
# aws s3api get-object-lock-configuration --bucket terraform-remote-s3-test-61893862
{
    "ObjectLockConfiguration": {
        "ObjectLockEnabled": "Enabled",
        "Rule": {
            "DefaultRetention": {
                "Mode": "COMPLIANCE",
                "Days": 1
            }
        }
    }
}

Note: this creates S3 buckets and objects that cannot be destroyed before the expiration of the retention delay (hard-coded to 1 day in the testing code).

image

image

image

image

@pdecat pdecat force-pushed the backend_s3_object_lock branch from 8700e35 to bed779a Compare December 21, 2021 10:19
@pdecat pdecat requested a review from a team as a code owner December 21, 2021 10:19
@hashicorp-cla
Copy link

hashicorp-cla commented Mar 12, 2022

CLA assistant check
All committers have signed the CLA.

@crw
Copy link
Contributor

crw commented May 24, 2022

Thanks for this submission! Although I cannot commit to having this PR reviewed at this time, we acknowledge your contribution and appreciate it! Thanks again!

@pdecat pdecat closed this Aug 24, 2023
@pdecat pdecat deleted the backend_s3_object_lock branch August 24, 2023 16:23
@pdecat
Copy link
Contributor Author

pdecat commented Aug 24, 2023

Closing as terraform is no longer open source software.

Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants