Terraform: Incorrect/inconsistent validation of -input option for terraform apply when option follows state file

Created on 4 Dec 2017  路  7Comments  路  Source: hashicorp/terraform

Terraform Version

Terraform v0.11.1

Terraform Configuration Files

n.a.

Expected Behavior

terraform apply tfplan -input=false should be valid input.

Actual Behavior

$ terraform apply tfplan -input=false  -no-color
Too many command line arguments. Configuration path expected.

Steps to Reproduce

See above

Important Factoids

This works fine:

$ terraform apply -input=false tfplan -no-color

Seems like terraform should either require that all options precede the plan file or not. The current behavior is inconsistent and confusing.

References

I see that the error is getting thrown from the ModulePath constructor in command/command.go line 69, which is called from command/apply.go line 66. I'm guessing that cmdFlags.Args() doesn't remove the -input=false argument, but wasn't able to dig into it further yet.

Thanks!

cli enhancement

Most helpful comment

I get the same error with :

terraform apply -auto-approve input=false -var=minNodes=3 -var=maxNodes=5 -var=k8s_cluster_name=cluster_1
Too many command line arguments. Configuration path expected.

All 7 comments

Hello,

Do you have any news related to this? I am trying to use VSTS but still am unable to use terraform apply due to this parameter being added automatically.

Thanks!

Can confirm this is still an issue, and is bloody annoying!

Actually, this is not an issue if you look at terraform documentation it is clear there:
terraform apply [options] [DIR-or-PLAN]
As long as you confine to the documentation then you will have no issue.

I get the same error with :

terraform apply -auto-approve input=false -var=minNodes=3 -var=maxNodes=5 -var=k8s_cluster_name=cluster_1
Too many command line arguments. Configuration path expected.

I am also facing with . the same issue

We hit this on 0.11.14 and 0.12.24.

also facing the same issue - I can confirm I got the plan successful and here's my debug trace.

2020/07/31 06:34:12 [INFO] Terraform version: 0.12.26  
822020/07/31 06:34:12 [INFO] Go runtime version: go1.12.13
832020/07/31 06:34:12 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply", "-auto-approve", "plan.tfplan", "-lock=true"}
842020/07/31 06:34:12 [DEBUG] Attempting to open CLI config file: /home/gitlab-runner/.terraformrc
852020/07/31 06:34:12 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
862020/07/31 06:34:12 [DEBUG] checking for credentials in "/home/gitlab-runner/.terraform.d/plugins"
872020/07/31 06:34:12 [DEBUG] checking for credentials in "/home/gitlab-runner/.terraform.d/plugins/linux_amd64"
882020/07/31 06:34:12 [INFO] CLI command args: []string{"apply", "-auto-approve", "plan.tfplan", "-lock=true"}
89Too many command line arguments. Configuration path expected.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

pawelsawicz picture pawelsawicz  路  3Comments

zeninfinity picture zeninfinity  路  3Comments

rkulagowski picture rkulagowski  路  3Comments

rjinski picture rjinski  路  3Comments

shanmugakarna picture shanmugakarna  路  3Comments