Terraform

Is it possible to combine conditionals and loop?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

Yes, for example:

dynamic "tag" {
  for_each = {
    for key, value in var.tags:
    key => value
    if key != ""
  }
}