Skip to content

Instantly share code, notes, and snippets.

@guillermo-musumeci
Created October 6, 2022 17:43
Show Gist options
  • Select an option

  • Save guillermo-musumeci/95944ed9f127328a0f0aaf6f3ec0508a to your computer and use it in GitHub Desktop.

Select an option

Save guillermo-musumeci/95944ed9f127328a0f0aaf6f3ec0508a to your computer and use it in GitHub Desktop.
Variable Validation in Terraform
variable "ip_address" {
type = string
description = "Web Server IP address"
validation {
condition = can(regex("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",var.ip_address))
error_message = "Invalid Web Server IP address provided"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment