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

terraform-validate doesn't work when modules are used. #540

Open
arianvp opened this issue Dec 19, 2024 · 1 comment · May be fixed by #541
Open

terraform-validate doesn't work when modules are used. #540

arianvp opened this issue Dec 19, 2024 · 1 comment · May be fixed by #541

Comments

@arianvp
Copy link

arianvp commented Dec 19, 2024

It always errors with:

+ /nix/store/jyxapkyfpi53p30x9kg4aqj66195bj43-opentofu-1.8.4/bin/tofu validate examples/nix-store-path
╷
│ Error: Module not installed
│ 
│   on examples/nix-store-path/main.tf line 36:
│   36: module "nixos_deploy_document" {
│ 
│ This module is not yet installed. Run "tofu init" to install all modules required by this configuration.
╵
+ read dir
@arianvp arianvp linked a pull request Dec 19, 2024 that will close this issue
@sestrella
Copy link
Contributor

I ran into the same issue; I believe this occurs mainly when running tofu validate on a project that was initialized with terraform init. However, IMHO, Terraform users should not be forced to use OpenTofu and vice versa; perhaps a better option would be to make both terraform-validate and terraform-format hooks support both Terraform and OpenTofu, or to add separate hooks for each.

Regarding the first option, I believe something similar to #419 should work within the scope of the terraform-validate hook. This should give users the flexibility to use Terraform or OpenTofu:

hooks = {
  terraform-validate = {
    enable = true;
    package = pkgs.opentofu # or pkgs.terraform
  };
}

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

Successfully merging a pull request may close this issue.

2 participants