我是Terraform的新手,我想知道如何使用它过滤标签,这意味着从名称标签“ email”开始,我们必须要求用户在值标签输入中输入特定格式“ [email protected]”。
我认为terraform的最新实验功能之一应该可以帮助您:
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
此功能需要满足以下条件:
terraform {
experiments = [variable_validation]
}
https://www.terraform.io/docs/configuration/variables.html#custom-validation-rules
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句