Now I am in process of migrating to Terraform 12. One of the main feature here is more strict HCL2 and I like it.
For example if I have list of maps:
elb_listeners = [
{
instance_port = 80
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
},
{
instance_port = 443
instance_protocol = "http"
lb_port = 443
lb_protocol = "https"
ssl_certificate_id = ARN certificate
}
I can spin it with dynamic block like:
dynamic "listener" {
for_each = [for listener in var.elb_listeners : {
instance_port = listener.instance_port
instance_protocol = listener.instance_protocol
lb_port = listener.lb_port
lb_protocol = listener.lb_protocol
}]
content {
instance_port = listener.value.instance_port
instance_protocol = listener.value.instance_protocol
lb_port = listener.value.lb_port
lb_protocol = listener.value.lb_protocol
}
}
But lets suppose I have only one block and only one block possible:
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
target = "HTTP:8000/"
interval = 30
}
I don't wish to declare all of these variables, I also want to describe this as block once in settings. Yes, here I also can use dynamic_block
with one element only but it will look as an overkill here. Is it possible to do that? Like
health_check {
var.health_check
}
or something.