# Terraform apply the destroy plan

**URL:** <https://discuss.hashicorp.com/t/terraform-apply-the-destroy-plan/17665>\
**Category:** Terraform\
**Created:** [November 15, 2020, 7:57pm UTC](https://discuss.hashicorp.com/t/terraform-apply-the-destroy-plan/17665 "2020-11-15T19:57:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gowthamakanthan](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/gowthamakanthan/32/10979_2.png) [@gowthamakanthan](https://discuss.hashicorp.com/u/gowthamakanthan)\
**Post date:** [November 15, 2020, 7:57pm UTC](https://discuss.hashicorp.com/t/terraform-apply-the-destroy-plan/17665/1 "2020-11-15T19:57:27Z")

</div>

Team,

Am using the terraform plan output to apply/destroy the infra. While using the `destroy` with the plan output, it’s throwing an error due to the `output.conf`. Is there a way to avoid executing `output.tf` when applying the destroy plan output?

FYI: `output.tf` is working fine with the plan and apply and throwing error with the apply with the destroy.out.

Work flow:

```auto
terraform plan -destroy --out=destroy.plan

> > Solicit Approval <<

terraform apply destroy.plan --auto-approve

```

Error:

```auto
+ terraform apply -auto-approve destroy.tfplan
local_file.render-vars: Destroying... [id=d3c23a19203e951f3c5b487bea62f35ae9689b40]
local_file.render-inventory: Destroying... [id=975618cb35e11872b89e50e8586fcc1b7cdbbe3b]
local_file.render-inventory: Destruction complete after 0s
local_file.render-vars: Destruction complete after 0s
module.server_vm.vsphere_virtual_machine.generic_vm[0]: Destroying... [id=42198817-56e4-f954-1f6b-486cf1fd434a]
module.client_vm.vsphere_virtual_machine.generic_vm[0]: Destroying... [id=42199433-7acb-ce1f-cb80-2e18ef8e6737]
module.client_vm.vsphere_virtual_machine.generic_vm[0]: Destruction complete after 9s
module.server_vm.vsphere_virtual_machine.generic_vm[0]: Destruction complete after 9s

Error: Error in function call

  on .terraform/modules/client_vm/output.tf line 4, in output "server_details":
   4: value = zipmap(
   5: 
   6: 
   7: 
    |----------------
    | var.generic_vm_type is tuple with 1 element
    | vsphere_virtual_machine.generic_vm is empty tuple

Call to function "zipmap" failed: number of keys (1) does not match number of
values (0).

Error: Error in function call

  on .terraform/modules/server_vm/output.tf line 4, in output "server_details":
   4: value = zipmap(
   5: 
   6: 
   7: 
    |----------------
    | var.generic_vm_type is tuple with 1 element
    | vsphere_virtual_machine.generic_vm is empty tuple

```

---

<div class="post-metadata">

**Author:** ![gowthamakanthan](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/gowthamakanthan/32/10979_2.png) [@gowthamakanthan](https://discuss.hashicorp.com/u/gowthamakanthan)\
**Post date:** [November 17, 2020, 2:20pm UTC](https://discuss.hashicorp.com/t/terraform-apply-the-destroy-plan/17665/2 "2020-11-17T14:20:59Z")

</div>

To add more info for my question. When i use plan output to do `terraform apply` which is working perfect.

When I use `terraform plan -destroy -out=destroy.tfplan```` and ` terraform apply destroy.tfplan``` it’s throwing the below-mentioned error.

The output conf which am using in the module and calling code is printed below.

In module:

```auto
output "server_details" {
  description = "This will print the type of the server and the ipadress(Based on the selection in the calling code)"
  value = zipmap(
    var.generic_vm_type.*.name,
    vsphere_virtual_machine.generic_vm.*.default_ip_address
  )
}

```

In calling code:

```auto
output "server_details" {
  description = "This will print the server type along with the ip"
  value = module.server_vm.server_details
} 

```

Error: Error in function call

```auto
  on .terraform/modules/client_vm/output.tf line 4, in output "server_details":
   4: value = zipmap(
   5: var.generic_vm_type.*.name,
   6: vsphere_virtual_machine.generic_vm.*.default_ip_address
   7: )
    |----------------
    | var.generic_vm_type is tuple with 1 element
    | vsphere_virtual_machine.generic_vm is empty tuple

Call to function "zipmap" failed: number of keys (1) does not match number of
values (0).

```

---

<div class="post-metadata">

**Author:** ![gtirloni](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/gtirloni/32/1363_2.png) [@gtirloni](https://discuss.hashicorp.com/u/gtirloni)\
**Post date:** [November 19, 2020, 6:38pm UTC](https://discuss.hashicorp.com/t/terraform-apply-the-destroy-plan/17665/3 "2020-11-19T18:38:57Z")

</div>

> <https://github.com/hashicorp/terraform/issues/522>
>
> For example, I have something like this:
> resource "aws\_vpc" "vpc" {
> cidr\_block = "10.0.0.0/16"
> }
> resource "aws\_internet\_gateway" "gateway" {
> vpc\_id = "${aws\_vpc.vpc.id}"
> }
> resource "aws\_elb" "elb"...

---

<div class="post-metadata">

**Author:** ![gowthamakanthan](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/gowthamakanthan/32/10979_2.png) [@gowthamakanthan](https://discuss.hashicorp.com/u/gowthamakanthan)\
**Post date:** [November 19, 2020, 9:13pm UTC](https://discuss.hashicorp.com/t/terraform-apply-the-destroy-plan/17665/4 "2020-11-19T21:13:19Z")

</div>

That’s helped. Thank you very much
