One way to achieve this with TF 0.12 onwards is to use dynamic blocks:
dynamic "access_logs" {
for_each = var.environment_name == "production" ? [var.environment_name] : []
content {
bucket = "my-bucket"
prefix = "${var.environment_name}-alb"
}
}
This will create one or zero access_logs blocks depending on the value of var.environment_name.