I\'m looking at using the new conditionals in Terraform v0.11 to basically turn a config block on or off depending on the evnironment.
Here\'s the b
Expanding on Juho Rutila's answer as it's too much to fit in a comment.
This is possible using dynamic blocks from v0.12, but I found the properties had to be included in a nested content block. The for_each statement is also a bit tricky, so I found it sensible to extract that into a local to make the important stuff more readable:
locals {
isProd = var.environment_name == "production" ? [1] : []
// Not necessary, but just illustrating that the reverse is possible
isNotProd = var.environment_name == "production" ? [] : [1]
}
dynamic "access_logs" {
for_each = local.isProd
content {
bucket = "my-bucket"
prefix = "${var.environment_name}-alb"
}
}
You can read more about dynamic blocks here: https://www.terraform.io/docs/configuration/expressions.html#dynamic-blocks