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 doesn't ask to input variables interactively? #3481

Closed
lawrencepit opened this issue Oct 12, 2015 · 8 comments
Closed

Terraform doesn't ask to input variables interactively? #3481

lawrencepit opened this issue Oct 12, 2015 · 8 comments

Comments

@lawrencepit
Copy link

Was following the Getting Started at http://www.terraform.io/intro/getting-started/variables.html:

UI Input: If you execute terraform plan or apply without doing anything, Terraform will ask you to input the variables interactively.

Got this instead:

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

Errors:

  * 2 error(s) occurred:

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

The other methods mentioned on that Getting Started page do seem to work.

@stack72
Copy link
Contributor

stack72 commented Oct 12, 2015

@lawrencepit I believe this is a mistake in the docs. This was added and then reverted. Right now, I believe that input defaults to false so it won't ask for them.

I usually use a tfvars file to load these types of variables. My tfvars file is then globally ignored by my git config

@lawrencepit
Copy link
Author

I later noticed the explicit -input=true in the command: apply doc, so I guess a mistake in the docs indeed.

PS. personally I don't like checking in files containing secrets such as aws keys/secrets. I believe Vault is the better solution for that ;-)

@stack72
Copy link
Contributor

stack72 commented Oct 12, 2015

@phinze Looks like there is a small mistake in the getting started docs:

**UI Input:** If you execute `terraform plan` or apply without doing
anything, Terraform will ask you to input the variables interactively.
These variables are not saved, but provides a nice user experience for
getting started with Terraform.

This isn't actually the case. By default, input is set to false. I suggest we change to something like

**UI Input:** By default, Terraform will *not* ask you to interactively input the variables if you execute `terraform plan` or apply without doing
anything. 

Thoughts?

@phinze
Copy link
Contributor

phinze commented Oct 12, 2015

Hm. This is confusing!

The relevant code is here, which says that unset variables should prompt for input iff no variables are specified in other ways (via tfvars or flags).

So, important question: was there a terraform.tfvars in the dir when the unexpected lack of prompt happened?

@lawrencepit
Copy link
Author

I followed the Getting Started page for Input Variables. The first step was Create another file variables.tf. I have no terraform.tfvars file.

I think what users would expect is that if a var is not defined via the command line, and then not defined in terraform.tfvars and finally not defined as a TF_VAR_* environment variable, then it falls back to UI input. Although tbh I'd prefer if by default it did not fall back to UI input (because I'd prefer automation without providing a -input=false each time). If you want the UI input fallback you'd have to be explicit by providing -input=true via the command line. Which btw also doesn't seem to work for me:

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

Errors:

  * 1 error(s) occurred:

* Required variable not set: foo

See also http://www.terraform.io/docs/commands/plan.html#_input_true

@aviflax
Copy link

aviflax commented Nov 11, 2015

New Terraform user here, and I’ve also been confused by the discrepancy between the Getting Started guide and the current behavior of the program. So I agree that either the behavior should be changed to match the docs, or the docs should be changed to match the behavior.


I’m also seeing the same problem as @lawrencepit wherein the -input flag does’t seem to work at all:

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

Errors:

  * 3 error(s) occurred:

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

So that should probably be fixed as well.

@phinze
Copy link
Contributor

phinze commented Nov 25, 2015

I believe this should be fixed in Terraform 0.6.7 by #3843 and #4017, which cause the input prompt behavior to be consistent across commands. Thanks to @jen20 for the fixes there!

@phinze phinze closed this as completed Nov 25, 2015
@ghost
Copy link

ghost commented Apr 29, 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 29, 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