Terraform – Variable 验证

variable "test" {
  validation {
    condition     = length(var.test) > 5
    error_message = "variable too short,must than 5 chars"
  }
}

output "result_test" {
  value = var.test
}
  1. 根据variable test的condition 数目,字数必须大于五就不会报错,否则报错信息就是error_message
  2. 以下是使用的返回结果

Loading

Facebook评论