1
0
Fork 0
terraform-training/02_variables/base.tf

48 lines
666 B
HCL

terraform {
experiments = [
variable_validation
]
}
variable "a" {
validation {
condition = can(regex("foo|aze|qsd", var.a))
error_message = "Valid values are foo, aze, qsd."
}
}
variable "b" {
default = "test"
}
variable "c" {
type = list
default = ["foo", "bar", "baz"]
}
variable "d" {
type = map
default = {
"foo" = "bar"
"aze" = "rty"
"qsd" = "fgh"
}
}
output "ov1" {
value = "${var.a}"
}
output "ov2" {
value = "${var.b}"
}
output "ov3" {
value = "${var.c[2]}"
}
output "ov4" {
value = "${var.d}"
}
output "ov4_foo" {
value = "${var.d.foo}"
}
output "ov4_lookup" {
value = "${lookup(var.d, var.a)}"
}