opentofu: data source with for_each don't evaluate postconditions
OpenTofu Version
1.8.4
OpenTofu Configuration Files
data "gitlab_project" "upstream" {
for_each = { for project in var.projects : project.path => project }
path_with_namespace = each.key
lifecycle {
postcondition {
condition = self.visibility_level == "public"
error_message = "must be public"
}
}
}
Debug Output
coming …
Expected Behavior
That the postcondition is evaluate for “each” element of the for_each data source.
Actual Behavior
The postcondition doesn’t seem to be evaluated even though the condition must evaluate to false.
I can show this by configuring an output that gives me the result of the conditions.
Steps to Reproduce
tofu plan
(I expect it to be evaluated during the plan)
Additional Context
There was a brief discussion on Slack here: https://opentofucommunity.slack.com/archives/C05R0FD0VRU/p1736497678504159
References
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 19 (14 by maintainers)
@ollevche and I had a brief debug session and it turns out that renaming the data source with the
for_each“fixes” the problem. We have three things to look into:selfnot correctly referencing thefor_eachobjects and maybe randomly picking an instancecc @abstractionfactory