I’ve been trying to make my Terraform Cloud (now HCP Terraform) setup cleaner and more reusable by leaning into variable sets — a powerful way to define shared configuration like tags, naming conventions, and environment-specific prefixes across multiple stacks. This approach is a lifesaver when you’re dealing with a growing number of workspaces and want to avoid duplicating boilerplate HCL in every single one.

But here’s the snag: locals in Terraform can’t reference values from variable sets.

This restriction seriously undermines the DRY (Don’t Repeat Yourself) principle. I often use locals to build structured objects—like shared tags or naming conventions—that I then pass into modules or resources. It’s neat, scalable, and consistent. Or at least, it would be if Terraform allowed it.

The Frustration in Code

Here’s a simplified version of what I tried to do:

store "varset" "global" {
  name     = "foo-global"
  category = "terraform"
}

# Constructing a shared tags object using a local
locals {
  common = {
    "Prefix" = store.varset.global.prefix
    "Owner"  = store.varset.global.owner
  }
}

This seems reasonable, right? But when running this in an HCP Terraform workspace that only gets prefix from a var set (not from .tfvars), Terraform chokes with an error like:

The message is clear: locals can only reference variables that are explicitly passed into the configuration. Variable sets, despite being globally scoped and injected at runtime, don’t count.

The Problem Statement

In a multi-stack architecture, it’s common to define shared patterns in a central place — naming schemes, required tags, toggles for environments, and so on. Variable sets feel tailor-made for this job. But without the ability to build reusable objects from those shared inputs using locals, you’re forced to repeat logic in modules or reconstruct the same objects inside every deployment.

The new HCL files that Terraform Stacks introduces supports locals but it seems like locals doesn’t support all the other goodness that Terraform Stacks has to offer!

The only real alternative is copy-pasta in HCL— exactly what I was trying to avoid.

Conclusion

I love what variable sets bring to Terraform Cloud: consistency, central management, and true reuse across stacks. But right now, their integration with locals is broken in a way that punishes abstraction and encourages duplication.

If you’re building out shared configuration and hoping to keep things dry, you’ll need to be extra careful — or brace for some brittle repetition in your *.tfdeploy.hcl files.