1
0
Fork 0

lookup and validation

This commit is contained in:
Cedric Girard 2020-05-12 12:17:38 +02:00
parent 0b5c77390a
commit cdfbca2bc6
Signed by: X-dark
GPG key ID: E7D0E125DB9519E4
4 changed files with 54 additions and 6 deletions

View file

@ -1,4 +1,15 @@
variable "a" {}
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"
}
@ -25,5 +36,12 @@ 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)}"
}

View file

@ -1,11 +1,11 @@
{
"version": 4,
"terraform_version": "0.12.24",
"serial": 9,
"serial": 11,
"lineage": "53b98038-185e-af43-6c6c-521354912695",
"outputs": {
"ov1": {
"value": "foobar",
"value": "foo",
"type": "string"
},
"ov2": {
@ -17,6 +17,21 @@
"type": "string"
},
"ov4": {
"value": {
"aze": "rty",
"foo": "bar",
"qsd": "fgh"
},
"type": [
"map",
"string"
]
},
"ov4_foo": {
"value": "bar",
"type": "string"
},
"ov4_lookup": {
"value": "bar",
"type": "string"
}

View file

@ -1,7 +1,7 @@
{
"version": 4,
"terraform_version": "0.12.24",
"serial": 8,
"serial": 10,
"lineage": "53b98038-185e-af43-6c6c-521354912695",
"outputs": {
"ov1": {
@ -13,7 +13,22 @@
"type": "string"
},
"ov3": {
"value": "fgh",
"value": "baz",
"type": "string"
},
"ov4": {
"value": {
"aze": "rty",
"foo": "bar",
"qsd": "fgh"
},
"type": [
"map",
"string"
]
},
"ov4_foo": {
"value": "bar",
"type": "string"
}
},

View file

@ -1 +1 @@
a = "foobar"
a = "foo"