I have a dynamic block like so:
dynamic "origin" {
for_each = var.ordered_cache_behaviors
content {
domain_name = "${origin.value.s3_target}.s3.amazonaws.com"
origin_id = "S3-${origin.value.s3_target}"
}
}
My list is defined like so:
"ordered_cache_behaviors": [
{
"path_pattern": "/my-app*",
"s3_target": "${local.default_s3_target}",
"ingress": "external"
}
]
In my dynamic block I want to render the block ONLY if this condition is true origin.value.s3_target !== var.default_s3_target
how and where do I add the conditional to my dynamic block? Note, the rendering of the block is controlled by the value of the currently iterated object not on some variable that excludes the for loop altogether.
I want to iterate over everything and conditionally exclude some items. So writing it in say Javascript it would look like this:
for (origin in ordered_cache_behaviors) {
if (origin.s3_target !== default_s3_target) {
renderContent();
} else {
console.log('Content was skipped!');
}
}