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

Fix Terraform missing init on subdirectory #548

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shikanime
Copy link
Contributor

@shikanime shikanime commented Jan 16, 2025

No description provided.

@shikanime shikanime changed the title Fix Terraform validate missing init on subdirectory Fix Terraform missing init on subdirectory Jan 16, 2025
@shikanime shikanime force-pushed the pr548 branch 2 times, most recently from d677cbb to 9d8e986 Compare January 16, 2025 10:59
@sandydoo
Copy link
Member

@shikanime, is this necessary for the fmt command?

@shikanime
Copy link
Contributor Author

shikanime commented Jan 21, 2025

Not necessary, if omitted it assumes the current directory is a terraform module. The current configuration will currently break if we try to format a submodule.

@shikanime
Copy link
Contributor Author

If I have a repository that has terraform module in subdirectory and the terraform fmt is runt in the root, it will complain that the current directory is not a terraform module such as:

root/ # Not a Terraform module
├─ envs/
   ├─ prod/ # Terraform module
   │  ├─ *.tf
   ├─ dev/ # Terraform module
      ├─ *.tf

@sandydoo
Copy link
Member

What if we use the -recursive flag?

@sandydoo
Copy link
Member

If I have a repository that has terraform module in subdirectory and the terraform fmt is runt in the root, it will complain that the current directory is not a terraform module such as:

Thanks for the repro. I'll look into this.

@sandydoo
Copy link
Member

sandydoo commented Jan 21, 2025

If I have a repository that has terraform module in subdirectory and the terraform fmt is runt in the root, it will complain that the current directory is not a terraform module such as:

root/ # Not a Terraform module
├─ envs/
   ├─ prod/ # Terraform module
   │  ├─ *.tf
   ├─ dev/ # Terraform module
      ├─ *.tf

I can't seem to replicate this. Both terraform and opentofu are happy to format the passed in files from any directory.

@shikanime
Copy link
Contributor Author

shikanime commented Jan 21, 2025

On second thought, I just checked my repositories, my mistake, it was only the validate command that complained about the missing init, sorry 🙏

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 this pull request may close these issues.

2 participants