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

tf hangs on terraform prompt #8

Closed
paldar opened this issue Jan 26, 2018 · 5 comments
Closed

tf hangs on terraform prompt #8

paldar opened this issue Jan 26, 2018 · 5 comments

Comments

@paldar
Copy link

paldar commented Jan 26, 2018

When one runs tf on a newly setup s3 backend, terraform prompts an interactive dialogue internally, but tf does not proxy the message to stdout/stderr, which causes the process to hang:

DEBUG: [terraform] Initializing the backend...
DEBUG: [terraform] Backend configuration changed!
DEBUG: [terraform]
DEBUG: [terraform] Terraform has detected that the configuration specified for the backend
DEBUG: [terraform] has changed. Terraform will now check for existing state in the backends.
DEBUG: [terraform]
DEBUG: [terraform]
DEBUG: [terraform] Do you want to copy existing state to the new backend?
DEBUG: [terraform]   Pre-existing state was found while migrating the previous "s3" backend to the
DEBUG: [terraform]   newly configured "s3" backend. An existing non-empty state already exists in
DEBUG: [terraform]   the new backend. The two states have been saved to temporary files that will be
DEBUG: [terraform]   removed after responding to this query.
DEBUG: [terraform]
DEBUG: [terraform]   Previous (type "s3"): /tmp/terraform485001133/1-s3.tfstate
DEBUG: [terraform]   New      (type "s3"): /tmp/terraform485001133/2-s3.tfstate
DEBUG: [terraform]
DEBUG: [terraform]   Do you want to overwrite the state in the new backend with the previous state?
DEBUG: [terraform]   Enter "yes" to copy and "no" to start with the existing state in the newly
DEBUG: [terraform]   configured "s3" backend.
DEBUG: [terraform]
@tmatilai
Copy link
Collaborator

tmatilai commented Jan 26, 2018

Gotcha, the command is missing the -input=false option!

I guess the command there is terraform init? It should be output a couple of lines before.

@tmatilai
Copy link
Collaborator

Actually, with the -input=false the command would fail. Not sure what would actually be the best way to handle the situation. Maybe Terraform would tell the what to do? Guess we'll have to find out. I'll push out a branch you can test.

@paldar
Copy link
Author

paldar commented Jan 26, 2018

the command here is tf <env> plan --debug, with backend configuration in tf.yaml:

backend:
  type: s3
  bucket: "BUCKETPREFIX-<%= @env %>"
  file: "environment_<%= @env %>.tfstate"
  region: "eu-west-1"

I removed the previously manually updated state file in the bucket, and a similar dialogue was prompted:

DEBUG: [terraform] Do you want to copy existing state to the new backend?
DEBUG: [terraform]   Pre-existing state was found while migrating the previous "s3" backend to the
DEBUG: [terraform]   newly configured "s3" backend. No existing state was found in the newly
DEBUG: [terraform]   configured "s3" backend. Do you want to copy this state to the new "s3"
DEBUG: [terraform]   backend? Enter "yes" to copy and "no" to start with an empty state.

@paldar
Copy link
Author

paldar commented Jan 26, 2018

indeed, it was trying to execute terraform init:

FATAL: Failed to execute `terraform init -no-color`

@tmatilai
Copy link
Collaborator

I created PR #9 which leads to the Terraform commands to fail if they need interaction. At least some error message is then printed with ERROR level message. This is not perfect, but I don't know what else we could do here. The migration would anyway most probably happen only when the user has done something uncommon, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants