Skip to content

terragrunt validate - issues with root terragrunt.hcl #40

Open

Description

@davehewy

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?

Activity

  1. yorinasub17 commented on Nov 10, 2020

    @yorinasub17
    Contributor

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

  2. davehewy commented on Nov 10, 2020

    @davehewy
    Author

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

  3. yorinasub17 commented on Nov 10, 2020

    @yorinasub17
    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.

  4. yorinasub17 commented on Nov 10, 2020

    @yorinasub17
    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.

  5. davehewy commented on Nov 12, 2020

    @davehewy
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions