beelit94 / python-terraform

MIT License
475 stars 171 forks source link

Apply Command hangs when using auto-approve #80

Closed Vishal2696 closed 4 years ago

Vishal2696 commented 4 years ago

I'm using Python3. I tried to run terraform apply using auto-approve tag. This resulted in the program standing still after plan. It was stuck and there was no progress nor error from the script. However, the program was executed successfully when the auto-approve was removed. Below is my code,

from python_terraform import *
terra = Terraform(working_dir='/home/terraformadmin/terraformpythonfiles/terrafiles')
terra.init_cmd(capture_output=False)
varfilepath="/home/terraformadmin/terraformpythonfiles/terrafiles/vnet-values.tfvars"
planargs = {"capture_output":False,"var-file":varfilepath}
terra.plan_cmd(**planargs)
approveargs = {"capture_output":False,"var-file":varfilepath,"auto-approve":True}
terra.apply(**approveargs)
Spikeophant commented 4 years ago

Are you using TF 0.12.x?

Spikeophant commented 4 years ago

Oh and version of python-terraform?

Vishal2696 commented 4 years ago

@Spikeophant python-terraform = 0.10.1 Terraform = 0.12.21

Vishal2696 commented 4 years ago

@Spikeophant Any update on this?

Spikeophant commented 4 years ago

At cli you pass auto-approve like terraform apply -auto-approve, if you read the readme for this project flags like that get set as auto_approve=IsFlagged not True. From the readme: terraform apply -no-color --> .apply(no_color=IsFlagged)

additionally you are using a dash which is explicitly called out in the documentation as well: dash to underscore

remove first dash, and then use underscore to replace dash symbol as option name

ex. -no-color --> no_color