(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')
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
Is it because of this? https://github.com/hashicorp/terraform/pull/27681
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!
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?