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

action hangs with terraform_wrapper: true when variables aren't defined #150

Open
jorupp opened this issue Feb 22, 2022 · 2 comments · May be fixed by #440
Open

action hangs with terraform_wrapper: true when variables aren't defined #150

jorupp opened this issue Feb 22, 2022 · 2 comments · May be fixed by #440
Labels
bug Something isn't working

Comments

@jorupp
Copy link

jorupp commented Feb 22, 2022

I was following https://learn.hashicorp.com/tutorials/terraform/github-actions, but forgot to prefix my environment variables with TF_VAR_, so they weren't being populated, causing terraform plan to prompt for them at runtime. However, with terraform_wrapper: true (the default), the terraform plan just ran for a while (I killed it after 10 minutes) without exiting. Once I disabled the wrapper, it exited with an error in a second. Based on that message, I was able to find and fix my error, and with that fixed, it worked with the wrapper again.

I wonder if terraform plan when run with the wrapper is waiting for an input that will never come to it's "enter a value for the variable" prompt? If so, I wonder if the fix involves passing an empty input to @actions/exec.exec?

const options = {
listeners,
ignoreReturnCode: true
};
const exitCode = await exec(pathToCLI, args, options);

@jorupp
Copy link
Author

jorupp commented Feb 23, 2022

Repro: https://github.com/jorupp/terraform-wrapper-test

Wrapper disabled, variable not defined

https://github.com/jorupp/terraform-wrapper-test/actions/runs/1888449826
Fails with:

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

Wrapper enabled, variable defined

https://github.com/jorupp/terraform-wrapper-test/actions/runs/1888449906

Succeeds

Wrapper enabled, variable not defined

https://github.com/jorupp/terraform-wrapper-test/actions/runs/1888450051

terraform plan ran for 20 minutes before I killed it.

@ksatirli ksatirli added the bug Something isn't working label Apr 4, 2022
hellais added a commit to ooni/devops that referenced this issue Feb 2, 2024
hellais added a commit to ooni/devops that referenced this issue Feb 6, 2024
@artemious7
Copy link

The solution is to add -input=false to every applicable terraform command, like so:

terraform plan -out=tfplan -input=false

See the docs for more info.

I think the Readme file here should reflect that. There is already a PR to fix the Readme file: #60. The discussion there suggests a solution to use an environment variable to disable requests for input, but it doesn't solve this problem since it has a different purpose (see here)

@artemious7 artemious7 linked a pull request Oct 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants