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

(1, '', '\nError: Failed to parse command-line flags\n\nflag provided but not defined: -force\n\nFor more help on using this command, run:\n terraform destroy -help\n') #108

Open
ARUNSOORAJPS opened this issue Jun 9, 2021 · 4 comments

Comments

@ARUNSOORAJPS
Copy link

ARUNSOORAJPS commented Jun 9, 2021

I have a terraform script which is able to destroy the instance using "terraform destroy" command. But I am getting an error while I try to do the same thing from python-terraform.

Please find the code I used for destroying the instance:

 from python_terraform import *
# my main.tf file is inside terraform folder where I am currently running this code.
var = Terraform(working_dir="terraform")
var.destroy(input=False)

Errror: (1, '', '\nError: Failed to parse command-line flags\n\nflag provided but not defined: -force\n\nFor more help on using this command, run:\n terraform destroy -help\n')

Versions:
python-terraform: 0.10.1
Terraform CLI: Terraform v1.0.0
on linux_amd64

@ARUNSOORAJPS
Copy link
Author

Is it because of this? hashicorp/terraform#27681

@EggyJohn
Copy link

Is it because of this? hashicorp/terraform#27681

must be, i've run into this issue today after updating from an older version of Terraform - how annoying!

@josehelps
Copy link

josehelps commented Jul 8, 2021

Ran into it as well, looks like latest terraform 1.0.x changed its behavior and lib is applying the -force flag by default here: https://github.com/beelit94/python-terraform/blob/develop/python_terraform/terraform.py#L146 .. things should work ok if you explicitly say not to flag it eg: terraform.destroy(capture_output='yes', no_color=IsNotFlagged, force=IsNotFlagged, auto_approve=True) and set the auto_approve to true instead. @beelit94 not sure if you are tracking this, but if I share a PR to update this to support latest terraform can you cut a new version of the library?

filipecosta90 added a commit to redis-performance/redisbench-admin that referenced this issue Nov 26, 2021
filipecosta90 added a commit to redis-performance/redisbench-admin that referenced this issue Nov 26, 2021
* [add] Added target tables grafana logic

* [fix] Fixes based on beelit94/python-terraform#108

* Bumping version from 0.5.21 to 0.5.22
filipecosta90 added a commit to redis-performance/redisbench-admin that referenced this issue Dec 1, 2021
… on (#248)

* [add] Added target tables grafana logic

* [fix] Fixes based on beelit94/python-terraform#108

* Bumping version from 0.5.21 to 0.5.22

* [add] Enabled keeping local env up via KEEP_ENV var

* [fix] Fixed profilers always on

* Bumping version from 0.5.22 to 0.5.23
@oberones
Copy link

This problem is super annoying but I finally figured out a good workaround. Since 0.15.2, terraform destroy has just been an alias for terraform apply -destroy, and the apply method does not have this bug. So you can do something like:

tf.apply(auto_approve=True, destroy=True, var=None)

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

4 participants