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

Exit with error if UI input scan fails #26509

Merged
merged 2 commits into from
Oct 21, 2020

Conversation

awsiv
Copy link
Contributor

@awsiv awsiv commented Oct 7, 2020

UPDATE: adding -input=false seems to do the trick as pointed out here. It might still make sense to keep the error handling though?


Fixes: #26508

Sample output:

Step 4/4 : RUN TF_LOG=DEBUG /terraform plan /tmp/
 ---> Running in f67cf0c83d8d
2020/10/07 20:12:22 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2020/10/07 20:12:22 [INFO] Terraform version: 0.14.0 dev 
2020/10/07 20:12:22 [INFO] Go runtime version: go1.15.2
2020/10/07 20:12:22 [INFO] CLI args: []string{"/terraform", "plan", "/tmp/"}
2020/10/07 20:12:22 [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2020/10/07 20:12:22 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/10/07 20:12:22 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2020/10/07 20:12:22 [DEBUG] ignoring non-existing provider search directory /root/.terraform.d/plugins
2020/10/07 20:12:22 [DEBUG] ignoring non-existing provider search directory /root/.local/share/terraform/plugins
2020/10/07 20:12:22 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2020/10/07 20:12:22 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2020/10/07 20:12:22 [INFO] CLI command args: []string{"plan", "/tmp/"}
2020/10/07 20:12:22 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2020/10/07 20:12:22 [DEBUG] New state was assigned lineage "ac8d3306-0318-ef71-e700-fc02993b217c"
2020/10/07 20:12:22 [DEBUG] checking for provisioner in "."
2020/10/07 20:12:22 [DEBUG] checking for provisioner in "/"
2020/10/07 20:12:22 [INFO] Failed to read plugin lock file .terraform/plugins/linux_amd64/lock.json: open .terraform/plugins/linux_amd64/lock.json: no such file or directory
2020/10/07 20:12:22 [INFO] backend/local: starting Plan operation
2020/10/07 20:12:22 [DEBUG] backend/local: will prompt for input of unset required variables [test]
2020/10/07 20:12:22 [DEBUG] command: asking for input: "var.test"
2020/10/07 20:12:22 [ERR] UIInput scan err: EOF
2020/10/07 20:12:22 [WARN] backend/local: Failed to request user input for variable "test": EOF
var.test
  Enter a value: e:
Error: No value for required variable

  on tmp/test.tf line 1:
   1: variable "test"{}

The root module input variable "test" is not set, and has no default value.
Use a -var or -var-file command line argument to provide a value for this
variable.

The command '/bin/sh -c TF_LOG=DEBUG /terraform plan /tmp/' returned a non-zero code: 1

@hashicorp-cla
Copy link

hashicorp-cla commented Oct 7, 2020

CLA assistant check
All committers have signed the CLA.

@pselle pselle requested a review from a team October 14, 2020 00:09
Copy link
Contributor

@alisdair alisdair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix makes sense to me, thanks! 🎉

@alisdair alisdair merged commit c41336b into hashicorp:master Oct 21, 2020
@awsiv awsiv deleted the UIInput_scan_err branch November 12, 2020 10:59
@ghost
Copy link

ghost commented Nov 21, 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 as resolved and limited conversation to collaborators Nov 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"terraform plan" proceeds even though a required variable is missing
3 participants