【发布时间】:2020-07-03 08:03:15
【问题描述】:
我是 Terraform 的新手,我想知道如何使用它过滤标签,我的意思是从名称标签“电子邮件”中,我们必须要求用户在值标签输入中输入特定格式“xxx@example.com” .
【问题讨论】:
标签: azure terraform terraform-provider-azure
我是 Terraform 的新手,我想知道如何使用它过滤标签,我的意思是从名称标签“电子邮件”中,我们必须要求用户在值标签输入中输入特定格式“xxx@example.com” .
【问题讨论】:
标签: azure terraform terraform-provider-azure
我认为 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
【讨论】: