feat(lib): add useLockfile to S3BackendConfig#217
Conversation
| * | ||
| * @default false | ||
| */ | ||
| readonly useLockfile?: boolean; |
There was a problem hiding this comment.
Given this is moving into past fork territory, we should consider using version validators such as
cdk-terrain/packages/cdktn/src/importable-resource.ts
Lines 26 to 32 in 178ea7f
would require a conditional validation on the config object having this set in the constructor
There was a problem hiding this comment.
confirmed support is in both OpenTofu and Terraform, both on version 1.10+
we should probably maintain our own version of cani.tf in the code (work for another PR)
There was a problem hiding this comment.
I agree that having a validation is good to add. I could definitely seeing increasing the minimum supported version in the near future, but not sure we would go all the way to 1.10 in the first jump.
| * | ||
| * @default false | ||
| */ | ||
| readonly useLockfile?: boolean; |
There was a problem hiding this comment.
I agree that having a validation is good to add. I could definitely seeing increasing the minimum supported version in the near future, but not sure we would go all the way to 1.10 in the first jump.
| bucket: "mybucket", | ||
| key: "path/to/my/key", | ||
| region: "us-east-1", | ||
| useLockfile: true, |
There was a problem hiding this comment.
Probably worth a test with false as well.
|
Created #237 as a base PR for Terraform/OpenTofu feature-version validation. It adds:
This should let this PR depend on/reuse the validator instead of encoding the version/product detection in the S3 backend change itself. For new ValidateTerraformFeatureVersion("S3 native state locking", {
terraform: ">=1.10.0",
opentofu: ">=1.10.0",
});If future features land in Terraform/OpenTofu at different versions, the same validator supports different constraints per CLI product. |
Description
Terraform 1.10 (Dec 2024) deprecated the S3 backend's
dynamodb_tableargumentin favor of
use_lockfile = true, which enables S3-native state locking via a<key>.tflockobject in the state bucket.S3BackendConfigwas forked fromCDKTF before this feature existed, so the typed prop was missing — users had to
fall back to escape hatches to set it.
This PR adds an optional
useLockfile?: booleanfield toS3BackendConfig.It's a pure pass-through to the rendered backend JSON (no validation,
no interaction with
dynamodbTable), so users can combine or migrate at theirown pace. Defaults to
falseto preserve existing behavior.Requires Terraform CLI ≥ 1.10 at apply time; documented in the JSDoc.
Checklist