gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
7.88k stars 964 forks source link

Terragrunt validate-inputs doesn't work with dependency blocks that require mocked values #3261

Open jmreicha opened 1 month ago

jmreicha commented 1 month ago

Describe the bug

When attempting to run the terragrunt validate-inputs command against a config file with a dependency block, it appears that the command does not attempt to use the same logic as the plan command for pulling mocked values, even when mock_outputs_allowed_terraform_commands = ["init", "plan", "validate"] is provided. I have tested this against other configs that don't pull in mocked data and it works well.

Hopefully I am missing something but didn't see any note about this in the docs.

Steps To Reproduce

Steps to reproduce the behavior, code snippets and examples which can be used to reproduce the issue.

This was simplified and cleaned. If you need a full reproduction I can update the reference here.

terraform {
  source = "my/module"
}

include "root" {
  path = find_in_parent_folders()
}

dependency "foo" {
  config_path  = "../foo"
  mock_outputs = "test"

  mock_outputs_allowed_terraform_commands = ["init", "plan", "validate", "output"]
  mock_outputs_merge_strategy_with_state  = "no_merge"
}

inputs = {
  foot = dependency.foo.outputs.bar
}

Expected behavior

I was expecting the validate-inputs command to pull the provided mocked output, but it appears to be skipping this.

Nice to haves

Error message when attempting to run the validate-inputs command against a config with dependency block (even with mocks).

ERRO[0002] /Users/josh.reichardt/git/lytx/github/terragrunt/account-a/permission-sets/foo/terragrunt.hcl is a dependency of /Users/josh.reichardt/git/lytx/github/terragrunt/account-a/assignments/foo/terragrunt.hcl but detected no outputs. Either the target module has not been applied yet, or the module has no outputs. If this is expected, set the skip_outputs flag to true on the dependency block.
ERRO[0002] Unable to determine underlying exit code, so Terragrunt will exit with error code 1

Running the same command against config with no dependency block produces expected output.

Versions

Additional context

jmreicha commented 1 month ago

terragrunt show seems to have this same problem even when a plan succeeds 🤔

Is there some way to tell it to skip refresh and/or not check outputs, since we know there won't be any from the mock configuration?

caspar-ds commented 1 month ago

Probably a similar problem to #3270