Terraform

There is a list variable called "users". You would like to define an output variable with a value of all users in uppercase but only if the name is longer than 3 characters. How to achieve that?

Difficulty: unrated

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

Answer

output "users" {
  value = [for name in var.user_names : upper(name) if length(name) > 3]
}