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
8.09k stars 981 forks source link

Missing Dependency Outputs Has Insufficiently Helpful Error Message #3567

Open yhakbar opened 2 days ago

yhakbar commented 2 days ago

Describe the bug

When a unit depends on outputs from another unit with no dependencies, it throws an error that looks like the following:

08:57:09.936 ERROR  error occurred:

* ./foo/terragrunt.hcl is a dependency of ./bar/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.

08:57:09.936 ERROR  Unable to determine underlying exit code, so Terragrunt will exit with error code 1

While the error does accurately describe the problem, it doesn't offer the best prescriptive guidance on how to fix the issue.

Steps To Reproduce

Create the following fixture:

mkdir foo
mkdir bar
touch foo/main.tf
touch bar/main.tf
touch foo/terragrunt.hcl
touch bar/terragrunt.hcl

Then populate bar/terragrunt.hcl with the following:

dependency "foo" {
    config_path = "../foo"
}

Expected behavior

The error that Terragrunt could not determine the underlying exit code should be removed, as it's clear what the underlying error is, and there should be a hint that a user could have used mocks to avoid the issue if they encountered the error during a plan of a dependency that wasn't applied yet.

Ideally, there should actually be an HCL sample emitted that a user could copy + paste to bypass the issue.

Nice to haves

Versions

Additional context

I encountered this as an expected error while writing up a guide for new users to adopt Terragrunt. These are the most important errors to get right, and they should be as good as possible.