-
-
Save chanux/8afa8c25bc198187eee892ab54063f3c to your computer and use it in GitHub Desktop.
Terraform: Typo in parameter name for object with two optionals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--- | |
# terraform plan -var complex='{one={name="jack", email="j@example.com", phon="121212"}}' | |
# | |
# This validation does not help catching typos because Terraform discards | |
# values not specified in the type, and without warning! | |
# | |
# https://github.com/hashicorp/terraform/issues/29204 | |
#-- | |
variable "complex" { | |
description = "Complex object with two optionals" | |
type = map(object({ | |
email = optional(string) | |
phone = optional(string) | |
})) | |
validation { | |
condition = alltrue( | |
flatten([ | |
for o in var.complex : | |
[for k in keys(o) : contains(["name", "email", "phone"], k)] | |
]) | |
) | |
error_message = "Did you make a typo" | |
} | |
} | |
output "complex" { | |
value = var.complex | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment