github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/testdata/show-json/conditions/main.tf (about) 1 variable "ami" { 2 type = string 3 default = "ami-test" 4 } 5 6 variable "id_minimum_length" { 7 type = number 8 default = 10 9 } 10 11 resource "test_instance" "foo" { 12 ami = var.ami 13 14 lifecycle { 15 precondition { 16 condition = can(regex("^ami-", var.ami)) 17 error_message = "Invalid AMI ID: must start with \"ami-\"." 18 } 19 } 20 } 21 22 resource "test_instance" "bar" { 23 ami = "ami-boop" 24 25 lifecycle { 26 postcondition { 27 condition = length(self.id) >= var.id_minimum_length 28 error_message = "Resource ID is unacceptably short (${length(self.id)} characters)." 29 } 30 } 31 } 32 33 output "foo_id" { 34 value = test_instance.foo.id 35 36 precondition { 37 condition = test_instance.foo.ami != "ami-bad" 38 error_message = "Foo has a bad AMI again!" 39 } 40 }