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

terragrunt validate - issues with root terragrunt.hcl #40

Open
davehewy opened this issue Nov 10, 2020 · 5 comments
Open

terragrunt validate - issues with root terragrunt.hcl #40

davehewy opened this issue Nov 10, 2020 · 5 comments

Comments

@davehewy
Copy link

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?

@yorinasub17
Copy link
Contributor

Just to confirm, is this an issue with a pre-commit hook you are using, or are you manually running terragrunt validate?

@davehewy
Copy link
Author

pre-commit. although it could be replicated using terragrunt validate

@yorinasub17
Copy link
Contributor

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.

@yorinasub17
Copy link
Contributor

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.

@davehewy
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants