pre-commit
pre-commit copied to clipboard
terragrunt validate - issues with root terragrunt.hcl
Failures in root terragrunt.hcl terragrunt validate. Consider the following dir structure
├── dev
│ └── eu-west-1
│ └── project
│ └── terragrunt.hcl
└── terragrunt.hcl
└── common.hcl
Where the child includes the parent via find_in_parent_folders()
.
If the parent has many read_terraform_config(find_in_parent_folders("common.hcl"))
type includes it will fail when terragrunt validate runs against it in singular. As the dir traversal fails to find the file.
Anything that can be done about this?
Just to confirm, is this an issue with a pre-commit hook you are using, or are you manually running terragrunt validate
?
pre-commit. although it could be replicated using terragrunt validate
Can you point to which pre-commit
hook runs terragrunt validate
? I don't see one in our list that runs terragrunt validate
(only terraform validate
).
In any case, I think this is a terragrunt issue so I will most likely migrate this over to that repo.
Also, this is sort of expected behavior since terragrunt validate
actually means to run terraform validate
for the given terragrunt configuration, and the root terragrunt config doesn't point to a terraform module (by definition), so even if we get past the syntax error, it will fail later in the pipeline when terragrunt checks for the existence of terraform code.
The pre-commit
hook for a terragrunt validate
call needs to be sure to ignore the root terragrunt config for this reason.
@yorinasub17 I got around this in the end by adding rules to the pre-commit cmd for terragrunt/terraform validate so that the root .hcl is ignored and that only files named terragrunt.hcl elsewhere where tested. example below
- id: terragrunt_validate
files: terragrunt.hcl
exclude: '^terraform/aws/terragrunt.hcl'
happy for this to be closed off