Skip to content

Adjust Design for Stack Values #3911

Open
@yhakbar

Description

Right now, there are some design problems with Stacks that we need to address.

The use of the unit.values prefixed variables is complicated to handle when using units outside the context of a stack, as it requires that all units recursively traverse the file system to discover the relevant terragrunt.stack.hcl file that generated them. It's also complicated by the fact that we have no simple way of detecting changes for units after they've been generated without doing some complex diffing on both unit configuration and stack values.

To resolve this, adjust the design of the stack values implementation to simply generate a new file to the side of terragrunt.hcl files named terragrunt.values.hcl.

It will be a simple HCL file with attributes named after their corresponding values.

e.g.

# terragrunt.stack.hcl
unit "thing" {
  source = "units/thing"
  path   = "thing"
  values = {
    foo = "foo-value"
    bar = "bar-value"
  }
}

Will generate the following:

# .terragrunt-stack/thing/terragrunt.hcl
input = {
	foo = values.foo
	bar = values.bar
}
# .terragrunt-stack/thing/terragrunt.values.hcl
foo = "foo-value"
bar = "bar-value"

Update the logic of unit configuration parsing to do automatically look for a local terragrunt.values.hcl file, and parse that for values used in values.xyz for unit configurations.

Make sure it can only be used with the stacks experiment, as we might need to iterate on this design.

Relates to #3313

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

enhancementNew feature or requeststacksIssues related to Stacks

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions