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 not working with root.hcl #3710

Open
sirantd opened this issue Dec 27, 2024 · 1 comment
Open

terragrunt validate not working with root.hcl #3710

sirantd opened this issue Dec 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@sirantd
Copy link

sirantd commented Dec 27, 2024

Describe the bug

There is a new recommendation to use root.hcl for the root Terragrunt file, but it breaks terragrunt validate (which I run as a pre-commit hook).

Steps To Reproduce

Rename terragrunt.hcl according to instructions

➜ terragrunt validate
20:05:52.682 INFO   Terragrunt Cache server is listening on 127.0.0.1:60287
20:05:52.683 INFO   Start Terragrunt Cache server
20:05:52.683 INFO   Shutting down Terragrunt Cache server...
20:05:52.684 INFO   Terragrunt Cache server stopped
20:05:52.684 ERROR  stat ./terragrunt.hcl: no such file or directory
20:05:52.684 ERROR  Unable to determine underlying exit code, so Terragrunt will exit with error code 1

Workaround

Place empty terragrunt.hcl in the root directory next to root.hcl

Versions

  • Terragrunt version: 0.71.1
  • OpenTofu/Terraform version: doesn't matter
  • Environment details (Ubuntu 20.04, Windows 10, etc.): MacOsX 15.2
@sirantd sirantd added the bug Something isn't working label Dec 27, 2024
@yhakbar
Copy link
Collaborator

yhakbar commented Jan 6, 2025

Hey @sirantd ,

Could you give me more details on how you're setting things up?

$ eza -T
.
├── root.hcl
├── unit1
│   ├── main.tf
│   └── terragrunt.hcl
├── unit2
│   ├── main.tf
│   └── terragrunt.hcl
└── unit3
    ├── main.tf
    └── terragrunt.hcl
fd -tf -x bash -c 'echo "# {}" && cat {} && echo'
# ./root.hcl

# ./unit1/main.tf

# ./unit1/terragrunt.hcl
include "root" {
        path = find_in_parent_folders("root.hcl")
}
# unit1
$ terragrunt validate
09:21:31.470 INFO   tofu: Initializing the backend...
09:21:31.470 INFO   tofu: Initializing provider plugins...
09:21:31.470 INFO   tofu: OpenTofu has been successfully initialized!
09:21:31.470 INFO   tofu:
09:21:31.470 INFO   tofu: You may now begin working with OpenTofu. Try running "tofu plan" to see
09:21:31.470 INFO   tofu: any changes that are required for your infrastructure. All OpenTofu commands
09:21:31.470 INFO   tofu: should now work.
09:21:31.470 INFO   tofu: If you ever set or change modules or backend configuration for OpenTofu,
09:21:31.470 INFO   tofu: rerun this command to reinitialize your working directory. If you forget, other
09:21:31.470 INFO   tofu: commands will detect it and remind you to do so if necessary.
09:21:31.489 STDOUT tofu: Success! The configuration is valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants