This snippet shows almost exactly what I'm trying to build. Except in my case I'm not setting an aws_lb's list of subnet_mapping, but rather an aws_cloudfront_distribution's list of origin. Specifically, note that origin contains custom_origin_config so it's a list of maps, where the map's value is a key to another map.
I tried doing this:
resource "aws_cloudfront_distribution" "foo" {
...
origin = "${null_resource.origins.*.triggers}"
...
}
resource "null_resource" "origins" {
count = "${length(var.origin_ids)}"
triggers {
domain_name = "${element(var.origin_domains, count.index)}"
origin_id = "${element(var.origin_ids, count.index)}"
custom_origin_config {
http_port = "${local.http_port}"
https_port = "${local.https_port}"
origin_protocol_policy = "http-only"
origin_ssl_protocols = "${local.origin_ssl_protocols}"
}
}
but I'm getting errors with:
... got unconvertible type '[]map[string]interface {}'