2

What's the common pattern for not duplicating variable values across plans?

We have a standard set of tags we use in plans and modules for which we wish to define once and use many. For example: we set CostType tag to values like compute, storage, etc.. We can define it plan level, or module level but that means defining a variable in multiple places which isn't very DRY (don't repeat yourself).

Options

  • non infrastructure changing module which defines these "global" variables and all modules/plans use that first so the rest of the actions can harvest the values from that plan

  • use a non infrastructure changing plan store remote state to store variable values and access it as from module/plans

  • use a tfvars file and handle it via the scripts that wrap terraform actions

  • devops elves magically handle this problem

How do you solve this problem in your organization?

Peter Kahn
  • 12,364
  • 20
  • 77
  • 135

1 Answers1

0

I used with success symbolic links to link the same variable file in multiple locations.

Symbolic links are well supported by Git and can be used on Windows too (with some care Git Symlinks in Windows).

Giulio Vian
  • 8,248
  • 2
  • 33
  • 41
  • For plans where I already use a tfvars file that might be a problem. I'm leaning towards tieing them to a remote nested tf module as we run a git repo for those and can easily wink them in. – Peter Kahn Jul 23 '18 at 17:59