I am new to Terraform and I was wondering how to filter tags with it, I mean from the name tag "email" we must require the user to enter a specific format "[email protected]" in the value tag input.
I think one of the recent experimental features of terraform should help you with that:
variable "email" {
type = string
validation {
condition = can(regex("^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$", var.email))
error_message = "ERROR: Not a valid email"
}
}
https://www.terraform.io/docs/configuration/functions/can.html
this feature requires this:
terraform {
experiments = [variable_validation]
}
https://www.terraform.io/docs/configuration/variables.html#custom-validation-rules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With