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 var-file arg #359

Closed
joe-dematteo opened this issue Nov 13, 2024 · 2 comments · Fixed by #360
Closed

Terraform validate var-file arg #359

joe-dematteo opened this issue Nov 13, 2024 · 2 comments · Fixed by #360
Assignees

Comments

@joe-dematteo
Copy link

Describe the bug

The terraform validate command is being passed the var-file arg.

To Reproduce

  - name: Terraform Action
    id: terraform-action
    uses: devsectop/tf-via-pr@v12.0.7
    with:
      command: "plan"
      plan-encrypt: ${{ secrets.PLAN_PASSPHRASE }}
      format: true
      validate: true
      comment-pr: recreate
      arg-var-file: "terraform.tfvars"

Expected behavior

The terraform validate command does not get passed the -var-file arg.

Additional context

Is the arg file supposed to be being passed to the Terraform validate command?

@rdhar
Copy link
Member

rdhar commented Nov 13, 2024

Hey @joe-dematteo, great spot! It seems like you've hit upon our first Terraform vs OpenTofu discrepancy:

This makes resolution a bit tricky on our end. Ideally, we don't need/want to know which version you're running, and simply pass along whatever inputs are supplied. But it becomes necessary to intervene when command arguments conflict.

In the short-term, I'll see to adding a basic terraform/tofu check to determine whether or not to pass -var-file to validate command. In the longer term, I want to avoid maintaining some kind of table of feature in/compatibilities between versions for as long as possible!

As an aside, since you're running a plan, a validate isn't really strictly necessary. As the docs state, "use the terraform plan command instead, which includes an implied validation check."

@rdhar
Copy link
Member

rdhar commented Nov 13, 2024

Happy to share this has been shipped with v12.0.8, where your contribution has been credited!

Please consider ⭐ this project, if you find it useful.

GitHub repository stargazers

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