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

auto-approve parameter is overwritten. #84

Open
msmaryrussell opened this issue Apr 21, 2020 · 6 comments
Open

auto-approve parameter is overwritten. #84

msmaryrussell opened this issue Apr 21, 2020 · 6 comments

Comments

@msmaryrussell
Copy link

The apply function in init.py seems to overwrite auto-approve. I have made a local change
in my copy of the code and it works by first checking if auto-approve has been set

I've added the if statement before the
if not default['auto-approve']:
default['auto-approve'] = (skip_plan == True)

I would like to contribute this fix if possible but starting with opening the issue - already mentioned
in an issue opened in 2018 "Terraform ignore -auto-approve=True"

@narasimha18sv
Copy link

yes for me while using executing terraform from windows when i use terraform apply functioni am getting " flag provided but not defined: -auto-approve " error.

@Spikeophant
Copy link
Collaborator

Yes this does happen, I will look at a fix.

@Spikeophant Spikeophant self-assigned this May 5, 2020
@Spikeophant Spikeophant changed the title auto-approve parameter is ignored auto-approve parameter is overwritten. May 5, 2020
@Spikeophant Spikeophant added this to the 0.10.2 milestone May 5, 2020
@Spikeophant
Copy link
Collaborator

I will address this in the rewrite I am going to do soon. If you'd like to help with the rewrite, or even planning for the rewrite let me know.

@narasimha18sv
Copy link

yes definitely I can help. Please let me know how we can collaborate.

@kingsleyadam
Copy link

It seems like providing the variable skip_plan will do the same thing. Correct?

It doesn't actually seem to skip the plan, but instead sets the auto-approve variable accordingly.

@next-jesusmanuelnavarro
Copy link

next-jesusmanuelnavarro commented Apr 8, 2024

First of all, thanks for this tool.

It seems I've been bitten by this bug too:

Code snippet:

apply_rc, apply_stdout, apply_stderr = tf_apply.apply(
	no_color = IsNotFlagged,
	auto_approve  = IsFlagged,
)

...results in (as per ps -ef):
terraform apply -var-file=/tmp/tmpxwdl2e2y.tfvars.json -input=false -auto-approve -auto-approve=false

OTOH, if I don't provide the auto_approve flag, that is:

apply_rc, apply_stdout, apply_stderr = tf_apply.apply(
	no_color = IsNotFlagged,
)

then ps shows: terraform apply -var-file=/tmp/tmpq_m51ld9.tfvars.json -input=false -auto-approve=false.

It seems -auto-approve=false is forcibly introduced by python_terraform code. Also notice that -auto-approve is a flag on Terraform 1.5.5, so it should be just -auto-approve instead of -auto-approve=[true|false].

NOTE:
The following options did terraform apply as intended:

  • Using apply method:
apply_rc, apply_stdout, apply_stderr = tf_apply.apply(
	no_color = IsNotFlagged,
	skip_plan = True,
	capture_output = True,
)

this turned into terraform apply -var-file=/tmp/tmp3972qoeq.tfvars.json -input=false -auto-approve=true

Testing right with terraform, it results that both -auto-approve and -auto-approve=[true|false] do the same thing (-auto-approve being equivalent to -auto-approve=true).

  • Using cmd method:
    This below also works as expected (terraform apply -auto-approve):
apply_rc, apply_stdout, apply_stderr = tf_apply.cmd(
	'apply',
	'-auto-approve',
	capture_output = True,
)

Also, this seems related to #45.

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

No branches or pull requests

5 participants