Skip to content

add support for S3 object based TF state lock#192

Merged
milldr merged 6 commits intocloudposse:mainfrom
smangels:feature/add-s3-object-based-state-lock
Aug 13, 2025
Merged

add support for S3 object based TF state lock#192
milldr merged 6 commits intocloudposse:mainfrom
smangels:feature/add-s3-object-based-state-lock

Conversation

@smangels
Copy link
Contributor

@smangels smangels commented Aug 6, 2025

what

This PR provides the code changes necessary to support Terraform state lock based on S3 object locks. It is closes #184 . I've decided to create the branch from release v1.5.0. Note that the change allow for smooth migration by keeping the DynamoDB related resources in place until all dependent deployments using the same framework have been migrated. After that the DynamoDB related switch can be changed to FALSE.

why

The Hashicorp Terraform project has marked the DynamoDB-based state lock as 'deprecated' and encourages the new TF state lock mechanism.

references

https://github.com/hashicorp/terraform/blob/v1.11/CHANGELOG.md#1110-february-27-2025

@smangels smangels requested review from a team as code owners August 6, 2025 06:49
@mergify mergify bot added the triage Needs triage label Aug 6, 2025
@milldr milldr added minor New features that do not break anything and removed triage Needs triage labels Aug 12, 2025
@milldr
Copy link
Member

milldr commented Aug 12, 2025

/terratest

Copy link
Member

@milldr milldr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the contribution!

@milldr milldr enabled auto-merge (squash) August 12, 2025 20:46
@plejd-sebman
Copy link
Contributor

Thanks for considering and handling the PR.

@milldr milldr merged commit 7193646 into cloudposse:main Aug 13, 2025
37 checks passed
@github-actions
Copy link

These changes were released in v1.6.0.

tags = module.this.tags
}

resource "aws_s3_bucket_object_lock_configuration" "default" {
Copy link

@jludiansonatype jludiansonatype Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smangels @plejd-sebman Not sure if this is the place to ask but I have this doubt. If TF S3 state locking use_lockfile property depends merely on s3 conditional writes. Why do we need this?

@plejd-sebman
Copy link
Contributor

@jludiansonatype this is required so that Terraform will be able to make use of native S3 state lock and for this a lock configuration has to be created. Otherwise this features is disabled on S3 objects in that bucket. Is there a special case where this solution doesn't work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support S3 Native State Locking

5 participants