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

plan/apply of a module fetches state files for indirect dependencies (json rendering enabled) #3538

Open
joaocc opened this issue Nov 8, 2024 · 3 comments
Labels
bug Something isn't working preserved Preserved issues never go stale

Comments

@joaocc
Copy link

joaocc commented Nov 8, 2024

Describe the bug

When executing run-all plan (or apply) even with --terragrunt-ignore-external-dependencies, both package and state file of indirect dependencies is also being fetched. This causes execution time to increase vastly.

Consider a module my-app/terragrunt.hcl has dependencies for my-cluster/ and my-defs/, and my-cluster/terragrunt.hcl has dependency for my-vpc/.
Executing a run-all plan on my-app/ should not need to install modules nor fetch state files of my-vpc/.

Expected behavior

Only fetch state of the direct dependencies.

Versions

  • Terragrunt version: v0.68.4
  • OpenTofu/Terraform version: v1.9.8
  • Environment details (Ubuntu 20.04, Windows 10, etc.): Debian 11
@joaocc joaocc added the bug Something isn't working label Nov 8, 2024
@denis256
Copy link
Member

denis256 commented Nov 8, 2024

Hello,
try setting env variable TERRAGRUNT_STRICT_CONTROL="skip-dependencies-inputs", it will improve performance at cost of skipping dependency inputs

@joaocc
Copy link
Author

joaocc commented Nov 11, 2024

Thanks. I was reading the docs and I am not sure if I am able to interpret correctly what this does.

  • Option 1: state files of direct dependency statements are not fetched (relying on local cache)
  • Option 2: state files of indirect dependency statements are not fetched
  • Other
    Thanks

@yhakbar
Copy link
Collaborator

yhakbar commented Nov 22, 2024

Hey @joaocc ,

We had a chat about this, and while the strict control that @denis256 mentioned does provide some optimizations for recursive fetching of dependencies it doesn't fully resolve the issue you're mentioning.

Terragrunt still inits in an ancestor dependency when it doesn't have to because of how it parses Terragrunt configurations (the relevant relatively inefficient code block is probably this one). While parsing the terragrunt.hcl file for a direct dependency to determine how to fetch outputs, Terragrunt ends up recursively traversing through ancestors to parse their configurations.

Preventing this behavior is going to take some adjustment in how we parse HCL configurations to do so safely, so please have patience as we look to resolve this issue. Of course, if you have your own thoughts on how to resolve this, you're welcome to submit a pull request!

@yhakbar yhakbar added the preserved Preserved issues never go stale label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working preserved Preserved issues never go stale
Projects
None yet
Development

No branches or pull requests

3 participants