Description
Since Terraform 1.9.0 and OpenTofu 1.9.0, a variable validation.condition may reference other objects (other variables, locals, data sources, resources) in addition to the variable itself. On older versions such a condition is a hard error.
CDKTN lets users build exactly that (Op.or(Op.neq(env.stringValue, "prod"), Fn.contains([...], size.stringValue)) inside size.addValidation(...)) and synthesizes it without complaint, although the default targetVersions floor is terraform >=1.5.7 / opentofu >=1.6.0.
Proposal
Register the existing ValidateFeatureTargetSupport (precedent: S3Backend.useLockfile, backends/s3-backend.ts:20-26) with { terraform: ">=1.9.0", opentofu: ">=1.9.0" } when a variable's resolved validation condition (or error message) references anything other than var.<own id>. Usage is only known at resolve time, so this likely wants the gated / resolve-discovered idiom from TerraformElement._registerProviderFeature() (GatedFeatureValidation).
Validation must stay declared-target based (no probing of the installed binary) — see #275.
References
cdktn-planning RFC 09 (terraform test support); #269 / #296 (targetVersions machinery).
Description
Since Terraform 1.9.0 and OpenTofu 1.9.0, a variable
validation.conditionmay reference other objects (other variables, locals, data sources, resources) in addition to the variable itself. On older versions such a condition is a hard error.CDKTN lets users build exactly that (
Op.or(Op.neq(env.stringValue, "prod"), Fn.contains([...], size.stringValue))insidesize.addValidation(...)) and synthesizes it without complaint, although the defaulttargetVersionsfloor isterraform >=1.5.7/opentofu >=1.6.0.Proposal
Register the existing
ValidateFeatureTargetSupport(precedent:S3Backend.useLockfile,backends/s3-backend.ts:20-26) with{ terraform: ">=1.9.0", opentofu: ">=1.9.0" }when a variable's resolved validation condition (or error message) references anything other thanvar.<own id>. Usage is only known at resolve time, so this likely wants the gated / resolve-discovered idiom fromTerraformElement._registerProviderFeature()(GatedFeatureValidation).Validation must stay declared-target based (no probing of the installed binary) — see #275.
References
cdktn-planning RFC 09 (
terraform testsupport); #269 / #296 (targetVersions machinery).