python-terraform icon indicating copy to clipboard operation
python-terraform copied to clipboard

Terraform ignore -auto-approve=True

Open ismail44 opened this issue 6 years ago • 4 comments

Using TF 0.11.10.

terraform apply -no-color -input=false -auto-approve=false /tmp/tmpurzm0_cx

When running this apply, terraform ran without prompting the user for yes. I suspect it's a change in the way that Terraform reads in the -auto-approve flag. According to the Terraform documentation, -auto-approve does not take any values, it's just a flag. I'm thinking that regardless of the value, Terraform is seeing the flag and applying auto-approve.

ismail44 avatar Dec 29 '18 13:12 ismail44

This worked for me

approve = {"auto-approve": True}

print(tf.plan())

x = (tf.apply( skip_plan=True,**approve))

chanduusc avatar Jan 15 '19 03:01 chanduusc

Hi,

I have used the below script and trying to execute terraform script but the terraform apply does not work

from python_terraform import * tf = Terraform(working_dir='/home/ubuntu/Amrutha/pshell') tf.plan(no_color=IsFlagged, refresh=False, capture_output=True) approve = {"auto-approve": True} print(tf.plan()) print(tf.apply(**approve))

Could you please let me know if iam missing put anything, as my required is to execute terraform apply with auto approve.

amruthapbhat avatar Apr 30 '19 06:04 amruthapbhat

whats the output?

chanduusc avatar Apr 30 '19 06:04 chanduusc

@amruthapbhat auto-approve won't work that way. You need to pass skip_plan=True to set auto-approve True. I'm not sure if this is the intended behaviour, but in the code, auto-approve is overwritten after it's passed based on skip_plan being True or False. @beelit94 Maybe you could answer this.

Lakshya2610 avatar May 11 '19 04:05 Lakshya2610