Is apply command safe if plan is failing

Hi team,

Is it true to suggest that terraform apply --non-interactive is actually safe to target environment and doesn’t make write API if plan or validation is broken. And the only difference is that we can’t differentiate which one of 3 actually failed (validate, plan or apply)?

Regards,
Serhii

Hi @chell0veck,

terraform apply doesn’t have a -non-interactive option, but based on the rest of your question I assume you mean -auto-approve which, essentially, automatically answers “yes” when reaching the step that would normally prompt for approval.

If the plan phase produces errors then the resulting plan is not applyable, so in that case terraform apply -auto-approve would not actually reach the part of the process where you would normally be prompted for approval. The apply phase therefore cannot begin.

As you’ve noted, this does mean that you won’t be able to determine which phase of the process actually failed, but any errors in one phase will prevent preceding to the next phase, regardless of whether “auto-approve” is enabled.

1 Like

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.