Terraform variable validation

From wikieduonline
Revision as of 16:16, 4 April 2023 by Welcome (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

validation variable validation [1]


variable "aws_region" {
 type        = string
 description = "region used to deploy workloads"
 default     = "us-east-1"
 validation {
   condition     = can(regex("^us-", var.aws_region))
   error_message = "The aws_region value must be a valid region in the USA, starting with \"us-\"."
 }
}


See also[edit]

  • https://www.hashicorp.com/blog/custom-variable-validation-in-terraform-0-13
  • Advertising: