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

var-file argument gives invalid format #3292

Closed
noahjl opened this issue Sep 21, 2015 · 4 comments
Closed

var-file argument gives invalid format #3292

noahjl opened this issue Sep 21, 2015 · 4 comments

Comments

@noahjl
Copy link

noahjl commented Sep 21, 2015

Using terraform 0.6.3 (on Fedora 22 x64) to deploy concurrent environments to AWS using -state and -var-file arguments.

The setup uses separate file for variables (variables.tf), outputs (outputs.tf) and resources ($resource.tf).

When deploying without the -var-file argument there is no issues. If I use the -var-file=variables.tf it throws an error that I suspect is a bug or user error. Different file names (i.e. demo.tfvars, demo_variables.tf) don't seem to make a difference.

$ terraform plan -var-file=variables.tf
...
2015/09/21 10:23:42 waiting for all plugin processes to complete...
invalid value "variables.tf" for flag -var-file: Error decoding Terraform vars file: root.variable: unknown type to string: ValueTypeObject

The vars file should be in the format of `key = "value"`.
Decoding errors are usually caused by an invalid format.
Usage: terraform plan [options] [dir]

  Generates an execution plan for Terraform.
...

Please let me know if any additional info would be helpful.
Thank you
Reviewed Issues #2659, #1084 as they seemed possibly related.

@ringods
Copy link
Contributor

ringods commented Oct 10, 2015

@noahjl You can't pass a *.tf file as a var-file argument.

In Terraform, you have two file types:

  • configuration: *.tf
  • variables: *.tfvars.

You must first declare your variables in e.g. test.tf file:

variable "test" {}

then you can provide a value via a variables file test.tfvars:

test = "value"

and run plan or push with the var-file argument:

$ terraform plan -var-file=test.tfvars
$ terraform push -var-file=test.tfvars

@phinze
Copy link
Contributor

phinze commented Oct 12, 2015

@ringods you gave a perfect explanation here - thank you!

@phinze phinze closed this as completed Oct 12, 2015
@mohamaa
Copy link

mohamaa commented Mar 21, 2016

Awesome explanation !!! worked like a charm.
One thing to note for a new bee : -var-file doesn't work with "terraform plan" command.

chids added a commit to chids/terraform that referenced this issue Apr 29, 2016
stack72 pushed a commit that referenced this issue Apr 29, 2016
xsellier pushed a commit to xsellier/terraform that referenced this issue May 17, 2016
@ghost
Copy link

ghost commented Apr 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants