Is it possible to turn the access_logs block on and off via the environment_name variable?

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)