github.com/hashicorp/packer@v1.14.3/hcl2template/testdata/variables/validation/valid.pkr.hcl (about) 1 2 variable "image_id" { 3 type = string 4 default = "ami-something-something" 5 validation { 6 condition = length(var.image_id) > 4 && substr(var.image_id, 0, 4) == "ami-" 7 error_message = "The image_id value must be a valid AMI id, starting with \"ami-\"." 8 } 9 } 10 11 source "null" "test" { 12 communicator = "none" 13 } 14 15 build { 16 sources = ["null.test"] 17 }