mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-14 02:32:39 -06:00
7ded73f266
Preconditions and postconditions for resources and data sources may not refer to the address of the containing resource or data source. This commit adds a parse-time validation for this rule.
56 lines
1.5 KiB
HCL
56 lines
1.5 KiB
HCL
resource "test" "test" {
|
|
lifecycle {
|
|
precondition {
|
|
condition = test.test.foo # ERROR: Invalid reference in precondition
|
|
error_message = "Cannot refer to self."
|
|
}
|
|
postcondition {
|
|
condition = test.test.foo # ERROR: Invalid reference in postcondition
|
|
error_message = "Cannot refer to self."
|
|
}
|
|
}
|
|
}
|
|
|
|
data "test" "test" {
|
|
lifecycle {
|
|
precondition {
|
|
condition = data.test.test.foo # ERROR: Invalid reference in precondition
|
|
error_message = "Cannot refer to self."
|
|
}
|
|
postcondition {
|
|
condition = data.test.test.foo # ERROR: Invalid reference in postcondition
|
|
error_message = "Cannot refer to self."
|
|
}
|
|
}
|
|
}
|
|
|
|
resource "test" "test_counted" {
|
|
count = 1
|
|
|
|
lifecycle {
|
|
precondition {
|
|
condition = test.test_counted[0].foo # ERROR: Invalid reference in precondition
|
|
error_message = "Cannot refer to self."
|
|
}
|
|
postcondition {
|
|
condition = test.test_counted[0].foo # ERROR: Invalid reference in postcondition
|
|
error_message = "Cannot refer to self."
|
|
}
|
|
}
|
|
}
|
|
|
|
data "test" "test_counted" {
|
|
count = 1
|
|
|
|
lifecycle {
|
|
precondition {
|
|
condition = data.test.test_counted[0].foo # ERROR: Invalid reference in precondition
|
|
error_message = "Cannot refer to self."
|
|
}
|
|
postcondition {
|
|
condition = data.test.test_counted[0].foo # ERROR: Invalid reference in postcondition
|
|
error_message = "Cannot refer to self."
|
|
}
|
|
}
|
|
}
|