mirror of
https://github.com/hashicorp/terraform.git
synced 2026-03-22 10:31:22 -04:00
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.
55 lines
1.5 KiB
HCL
55 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."
|
|
}
|
|
}
|
|
}
|