Added some basic variable validation

This commit is contained in:
Julio Castillo 2020-11-03 08:00:16 +01:00
parent 352b7a0645
commit 7bd31ccf52
5 changed files with 25 additions and 7 deletions

View File

@ -97,6 +97,10 @@ variable "type" {
description = "Type of zone to create, valid values are 'public', 'private', 'forwarding', 'peering', 'service-directory'."
type = string
default = "private"
validation {
condition = contains(["public", "private", "forwarding", "peering", "service-directory"], var.type)
error_message = "Zone must be one of 'public', 'private', 'forwarding', 'peering', 'service-directory'."
}
}
variable "zone_create" {
@ -106,3 +110,4 @@ variable "zone_create" {
}

View File

@ -88,6 +88,10 @@ variable "storage_class" {
description = "Bucket storage class."
type = string
default = "MULTI_REGIONAL"
validation {
condition = contains(["STANDARD", "MULTI_REGIONAL", "REGIONAL", "NEARLINE", "COLDLINE", "ARCHIVE"], var.storage_class)
error_message = "Storage class must be one of STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE."
}
}
variable "versioning" {

View File

@ -100,6 +100,11 @@ variable "routing_mode" {
description = "The network routing mode (default 'GLOBAL')"
type = string
default = "GLOBAL"
validation {
condition = var.routing_mode == "GLOBAL" || var.routing_mode == "REGIONAL"
error_message = "Routing type must be GLOBAL or REGIONAL."
}
}
variable "shared_vpc_host" {

View File

@ -83,6 +83,10 @@ variable "parent" {
description = "Parent folder or organization in 'folders/folder_id' or 'organizations/org_id' format."
type = string
default = null
validation {
condition = can(regex("(organizations|folders)/[0-9]+", var.parent))
error_message = "Parent must be of the form folders/folder_id or organizations/organization_id."
}
}
variable "policy_boolean" {