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

.tfvars file doesn't seem to be loaded by default #59

Closed
seanherron opened this issue Jul 28, 2014 · 11 comments
Closed

.tfvars file doesn't seem to be loaded by default #59

seanherron opened this issue Jul 28, 2014 · 11 comments
Labels

Comments

@seanherron
Copy link
Contributor

According to the documentation, a file with the extension .tfvars should be loaded automatically. However, in practice this doesn't seem to be occurring for me.

I have a terraform.tfvars file with the following contents:

access_key = "myaccesskey"
secret_key = "mysecretkey"

However, running terraform plan doesn't seem to include those variables:

$ terraform plan
There are warnings and/or errors related to your configuration. Please
fix these before continuing.

Errors:

  * Required variable not set: access_key
  * Required variable not set: secret_key

Running terraform plan -var-file=terraform.tfvars, however, does work:

$ terraform plan -var-file=terraform.tfvars
Refreshing Terraform state prior to plan...


No changes. Infrastructure is up-to-date. This means that Terraform
could not detect any differences between your configuration and
the real physical resources that exist. As a result, Terraform
doesn't need to do anything.

Am I missing something?

@mitchellh
Copy link
Contributor

This is a bug. Thanks.

@mitchellh mitchellh added the bug label Jul 28, 2014
@gaffneyc
Copy link

Since it's not implemented yet, what about considering renaming it to just .tfvars? That way it will be a hidden file on Unix at least.

@mitchellh
Copy link
Contributor

@gaffneyc That's not a bad idea, but would conflict with the fact we use terraform.tfstate as the default state thing. Honestly I wouldn't mind supporting both. For example, with override files (if you've read about those yet), it can be named override.tf or anything endingin _override.tf. I think supporting both wouldn't be too bad here.

@NicolasMas
Copy link

Hi all, I reproduced it:
image

@mitchellh
Copy link
Contributor

Fixed

@alekstorm
Copy link
Contributor

I'm -1 on supporting .tfvars as a hidden file. Sounds like a trap for new users ("where are my variables coming from?").

@seanherron
Copy link
Contributor Author

@alekstorm it's not a hidden file. For instance, my variables are stored invariables.tfvars.

@alekstorm
Copy link
Contributor

An earlier commenter floated the idea of renaming it to literally .tfvars (see #59 (comment)).

@seanherron
Copy link
Contributor Author

@alekstorm Ah, see that now, nevermind :) Agree with @mitchellh on the idea of supporting both.

@gaffneyc
Copy link

@alekstorm my understanding is that the terraform.tfvars (or my suggested just .tfvars) file would be excluded from source control. It shouldn't be a surprise for new users since they should be putting the file in place themselves.

I agree that supporting both would be good.

@ghost
Copy link

ghost commented Apr 23, 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 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants