terraform destroy: flag provided but not defined: -auto-approve

Created on 21 Feb 2018  ·  9Comments  ·  Source: hashicorp/terraform

Terraform Version
terraform --version
Terraform v0.11.3

  • provider.aws v1.9.0

Issue: terraform destroy doesn't support '--auto-approve' options
Output:

terraform destroy -auto-approve 
flag provided but not defined: -auto-approve
Usage: terraform destroy [options] [DIR]

  Destroy Terraform-managed infrastructure.

Options:

  -backup=path           Path to backup the existing state file before
                         modifying. Defaults to the "-state-out" path with
                         ".backup" extension. Set to "-" to disable backup.

  -force                 Don't ask for input for destroy confirmation.

  -lock=true             Lock the state file when locking is supported.

  -lock-timeout=0s       Duration to retry a state lock.

  -no-color              If specified, output won't contain any color.

  -parallelism=n         Limit the number of concurrent operations.
                         Defaults to 10.

  -refresh=true          Update state prior to checking for differences. This
                         has no effect if a plan file is given to apply.

  -state=path            Path to read and save state (unless state-out
                         is specified). Defaults to "terraform.tfstate".

  -state-out=path        Path to write state to that is different than
                         "-state". This can be used to preserve the old
                         state.

  -target=resource       Resource to target. Operation will be limited to this
                         resource and its dependencies. This flag can be used
                         multiple times.

  -var 'foo=bar'         Set a variable in the Terraform configuration. This
                         flag can be set multiple times.

  -var-file=foo          Set variables in the Terraform configuration from
                         a file. If "terraform.tfvars" or any ".auto.tfvars"
                         files are present, they will be automatically loaded.
documentation

Most helpful comment

Yes, the -force flag is what you want to skip confirmation.

All 9 comments

Hi @MagicZou,

Sorry, I'm not sure I understand the issue here.
You've provided the -auto-approve flag to destroy, but it's not a flag defined for that command. The error output states this, and the usage info for the command doesn't show it as an option either.

Since the apply command now requires a plan, or the manual acceptance of a new plan, the -auto-approve flag was added to allow users a way to restore the legacy behavior without breaking their automation.

Hi,

I also want to automate the ‘terraform destroy’ command without typing ‘yes’. I was reading the command documentation, which says the ‘destroy’ supports the same options as ‘apply’. That’s why I am trying ‘-auto-prove’ in ‘destroy’, simply cause ‘apply’ supports it.
In this case, should I go with ‘-force’ in ‘destroy’?

Yes, the -force flag is what you want to skip confirmation.

thanks

Ah, I see the line in the website docs that needs updating.
We'll take care of that too.
Thanks!

Even i fell the same rabbit hole! Would be great if someone updates the documentation

@kiran002,

-auto-approve has since been added to the destroy command for parity, and the documented was updated to reflect that.

@jbardin

Ah i see, I was using version 0.11.3 and this was the reason, i still got the error. Thanks for pointing out!

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings