You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into the issue, that freshly checked out, the pre-commit configuration failed with this already known issue for me:
🛰️ ❯ pre-commit run --all-files
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
mixed line ending........................................................Passed
Terragrunt fmt...........................................................Passed
Terragrunt validate......................................................Failed
- hook id: terragrunt_validate
- exit code: 1
19:57:52.689 ERROR stat ./terragrunt.hcl: no such file or directory
19:57:52.689 ERROR Unable to determine underlying exit code, so Terragrunt will exit with error code 1
It appears to me that if you give any directory without a terragrunt.hcl file to terragrunt_validate this error occurs.
The issue seems to stem from the fact that there apparently needs to be a terragrunt.hcl file everywhere (although in antonbabenko/pre-commit-terraform#191 it already looks like it should only run where a .hcl file exists.
Additionally please look at this comment in the same issue where it seems like root.hcl is a bad name if we want the file to be validated.
I used the versions in this repo and also the newest ones available (5.0.0 and 1.96.1 respectively) with not difference in behaviour.
This MR appears to me not as the best solution, but maybe its a solution to get pre-commit to cleanly run through?
This is a good and working fix for the problem. Thank you for contributing! I simplified the regex a little bit, but the change is in the same nature.
When there is an error in root.hcl the terragrunt_validate pre-commit hook will find it when evaluating the root modules which include the root.hcl. Therefore exluding the file in the terragrunt_validate regex doesn't mean it will not check the root.hcl.
I read the linked issues and comments. There is a good reason for naming the top-level Terragrunt file root.hcl instead of terragrunt.hcl. Running terragrunt run-all plan in the environments folder runs without errors. This means every root module can be planed with one command. When naming this file terragrunt.hcl Terragrunt identifies this file as the entrypoint for a root module itself and tries to create a plan. This plan then fails.
Nonetheless this error when using terragrunt run-all isn't obvious and easily searchable. I added more context to the README for clarification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I ran into the issue, that freshly checked out, the pre-commit configuration failed with this already known issue for me:
It appears to me that if you give any directory without a
terragrunt.hclfile toterragrunt_validatethis error occurs.The issue seems to stem from the fact that there apparently needs to be a
terragrunt.hclfile everywhere (although in antonbabenko/pre-commit-terraform#191 it already looks like it should only run where a.hclfile exists.Additionally please look at this comment in the same issue where it seems like
root.hclis a bad name if we want the file to be validated.I used the versions in this repo and also the newest ones available (
5.0.0and1.96.1respectively) with not difference in behaviour.This MR appears to me not as the best solution, but maybe its a solution to get pre-commit to cleanly run through?