mirror of https://github.com/hashicorp/terraform
This allows precondition and postcondition checks to be declared for resources and output values as long as the preconditions_postconditions experiment is enabled. Terraform Core doesn't currently know anything about these features, so as of this commit declaring them does nothing at all.pull/30401/head
parent
82c518209d
commit
9076400436
@ -0,0 +1,34 @@
|
||||
resource "test" "test" {
|
||||
lifecycle {
|
||||
precondition {
|
||||
condition = true # ERROR: Invalid precondition expression
|
||||
error_message = "Must be true."
|
||||
}
|
||||
postcondition {
|
||||
condition = true # ERROR: Invalid postcondition expression
|
||||
error_message = "Must be true."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "test" "test" {
|
||||
lifecycle {
|
||||
precondition {
|
||||
condition = true # ERROR: Invalid precondition expression
|
||||
error_message = "Must be true."
|
||||
}
|
||||
postcondition {
|
||||
condition = true # ERROR: Invalid postcondition expression
|
||||
error_message = "Must be true."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = ""
|
||||
|
||||
precondition {
|
||||
condition = true # ERROR: Invalid precondition expression
|
||||
error_message = "Must be true."
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
data "test" "foo" {
|
||||
lifecycle {}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
data "example" "example" {
|
||||
lifecycle {
|
||||
# This block intentionally left blank
|
||||
# The lifecycle arguments are not valid for data resources:
|
||||
# only the precondition and postcondition blocks are allowed.
|
||||
ignore_changes = []
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
resource "test" "test" {
|
||||
lifecycle {
|
||||
precondition { # ERROR: Preconditions are experimental
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
postcondition { # ERROR: Postconditions are experimental
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "test" "test" {
|
||||
lifecycle {
|
||||
precondition { # ERROR: Preconditions are experimental
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
postcondition { # ERROR: Postconditions are experimental
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = ""
|
||||
|
||||
precondition { # ERROR: Preconditions are experimental
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
terraform {
|
||||
experiments = [preconditions_postconditions] # WARNING: Experimental feature "preconditions_postconditions" is active
|
||||
}
|
||||
|
||||
resource "test" "test" {
|
||||
lifecycle {
|
||||
precondition {
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
postcondition {
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "test" "test" {
|
||||
lifecycle {
|
||||
precondition {
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
postcondition {
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = ""
|
||||
|
||||
precondition {
|
||||
condition = path.module != ""
|
||||
error_message = "Must be true."
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue