Skip to content

Support project-wide default for mock_outputs_allowed_terraform_commands in dependency blocks #6257

Description

@VictorColomb

Describe the enhancement

Add a way to set a project-wide default value for mock_outputs_allowed_terraform_commands so it does not need to be repeated on every dependency block.

Today, every dependency block that uses mock_outputs must also explicitly declare which commands are allowed to use those mocks. In a large repo this setting is almost always identical across every unit, resulting in significant boilerplate that is easy to forget and tedious to keep consistent.

dependency "vpc" {
  config_path = "../vpc"
  mock_outputs_allowed_terraform_commands = ["plan", "validate"]
  mock_outputs = { vpc_id = "mock-vpc-id" }
}

Additional context

Implementation suggestion: A dependency_defaults (I'm not married to the name) block in the root HCL file that is merged into every dependency block. Individual blocks can still override the default.

# root.hcl
dependency_defaults {
  mock_outputs_allowed_terraform_commands = ["plan", "validate"]
}

Implications of the feature: The per-block mock_outputs_allowed_terraform_commands value can take precedence, therefore this would be a non-breaking change.

Alternatives considered:

  • Without any changes to terragrunt, use read_terragrunt_config to pull in a shared snippet. This solves the consistency part, but it still requires each dependency block to reference it.
  • Similarly, expose the root.hcl locals in which you've defined e.g. mock_outputs = ["plan", "validate"].
  • CLI argument / environment variable that disables mock outputs, e.g. terragrunt apply --all --no-mock-outputs.

PoC (Proof of Concept)

No

RFC Not Needed

  • I have evaluated the complexity of this enhancement, and I believe it does not require an RFC.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions