github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/website/intro/getting-started/destroy.html.md (about) 1 --- 2 layout: "intro" 3 page_title: "Destroy Infrastructure" 4 sidebar_current: "gettingstarted-destroy" 5 description: |- 6 We've now seen how to build and change infrastructure. Before we move on to creating multiple resources and showing resource dependencies, we're going to go over how to completely destroy the Terraform-managed infrastructure. 7 --- 8 9 # Destroy Infrastructure 10 11 We've now seen how to build and change infrastructure. Before we 12 move on to creating multiple resources and showing resource 13 dependencies, we're going to go over how to completely destroy 14 the Terraform-managed infrastructure. 15 16 Destroying your infrastructure is a rare event in production 17 environments. But if you're using Terraform to spin up multiple 18 environments such as development, test, QA environments, then 19 destroying is a useful action. 20 21 ## Destroy 22 23 Resources can be destroyed using the `terraform destroy` command, which is 24 similar to `terraform apply` but it behaves as if all of the resources have 25 been removed from the configuration. 26 27 ``` 28 $ terraform destroy 29 # ... 30 31 - aws_instance.example 32 ``` 33 34 The `-` prefix indicates that the instance will be destroyed. As with apply, 35 Terraform shows its execution plan and waits for approval before making any 36 changes. 37 38 Answer `yes` to execute this plan and destroy the infrastructure: 39 40 ``` 41 # ... 42 aws_instance.example: Destroying... 43 44 Apply complete! Resources: 0 added, 0 changed, 1 destroyed. 45 46 # ... 47 ``` 48 49 Just like with `apply`, Terraform determines the order in which 50 things must be destroyed. In this case there was only one resource, so no 51 ordering was necessary. In more complicated cases with multiple resources, 52 Terraform will destroy them in a suitable order to respect dependencies, 53 as we'll see later in this guide. 54 55 ## Next 56 57 You now know how to create, modify, and destroy infrastructure 58 from a local machine. 59 60 Next, we move on to features that make Terraform configurations 61 slightly more useful: [variables, resource dependencies, provisioning, 62 and more](/intro/getting-started/dependencies.html).