mirror of https://github.com/hashicorp/terraform
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.pull/30462/head
parent
0634c9437a
commit
7ded73f266
@ -0,0 +1,55 @@
|
||||
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."
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue