Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about unused dependencies #3903

Open
1 task done
BeyondEvil opened this issue Feb 19, 2025 · 3 comments
Open
1 task done

Warn about unused dependencies #3903

BeyondEvil opened this issue Feb 19, 2025 · 3 comments
Labels
enhancement New feature or request preserved Preserved issues never go stale

Comments

@BeyondEvil
Copy link

Describe the enhancement

It'd be swell if there was some way, either when running init/plan/apply or any other validation command, if Terragrunt warned about unused dependency blocks.

RFC Not Needed

  • I have evaluated the complexity of this enhancement, and I believe it does not require an RFC.
@BeyondEvil BeyondEvil added the enhancement New feature or request label Feb 19, 2025
@yhakbar yhakbar added the preserved Preserved issues never go stale label Feb 19, 2025
@mhulscher
Copy link

How would you define an unused dependency? If none of its outputs are used? Personally, I sometimes use (explicit) dependency blocks w/o outputs and I wouldn't need to be reminded of that 😅

@BeyondEvil
Copy link
Author

BeyondEvil commented Feb 20, 2025

How would you define an unused dependency? If none of its outputs are used? Personally, I sometimes use (explicit) dependency blocks w/o outputs and I wouldn't need to be reminded of that 😅

Interesting. What's the use-case for a dependency block that's not used? 🤔

Regardless, that's probably and edge case that could be solved with a "don't warn"-attribute in the block.

To answer your question, your use-case not withstanding, if there's a dependency block defined - but not called, a warning is issued.

Meaning, if we have:

dependency "foo" {
}

But no calls to dependency.foo, it warrants a warning.

@yhakbar
Copy link
Collaborator

yhakbar commented Feb 20, 2025

Defining a dependency without using any outputs gives Terragrunt information on its relationship in the DAG.

It's useful, even though someone could theoretically do the same thing via a dependencies block, which can't define outputs.

I think what would be more useful here is some type of lint that can warn on that for users trying to discover dependencies without used outputs.

We don't have a dedicated Terragrunt linter right now, but we will have an hcl lint command after the CLI Redesign. It might be a good feature to add there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request preserved Preserved issues never go stale
Projects
None yet
Development

No branches or pull requests

3 participants