Organizing Logic
Sometimes you need to combine strings or perform logic that doesn't need to be an input from a user. We use locals for this.
hcl locals { service_name = "frontend" owner = "devops-team" common_tags = { Service = local.service_name Owner = local.owner } }
resource "aws_instance" "web" { tags = local.common_tags }
Locals make your code cleaner and help avoid repeating the same logic multiple times.