github.com/jmbataller/terraform@v0.6.8-0.20151125192640-b7a12e3a580c/website/source/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 ## Plan 22 23 Before destroying our infrastructure, we can use the plan command 24 to see what resources Terraform will destroy. 25 26 ``` 27 $ terraform plan -destroy 28 ... 29 30 - aws_instance.example 31 ``` 32 33 With the `-destroy` flag, we're asking Terraform to plan a destroy, 34 where all resources under Terraform management are destroyed. You can 35 use this output to verify exactly what resources Terraform is managing 36 and will destroy. 37 38 ## Destroy 39 40 Let's destroy the infrastructure now: 41 42 ``` 43 $ terraform destroy 44 aws_instance.example: Destroying... 45 46 Apply complete! Resources: 0 added, 0 changed, 1 destroyed. 47 48 ... 49 ``` 50 51 The `terraform destroy` command should ask you to verify that you 52 really want to destroy the infrastructure. Terraform only accepts the 53 literal "yes" as an answer as a safety mechanism. Once entered, Terraform 54 will go through and destroy the infrastructure. 55 56 Just like with `apply`, Terraform is smart enough to determine what order 57 things should be destroyed. In our case, we only had one resource, so there 58 wasn't any ordering necessary. But in more complicated cases with multiple 59 resources, Terraform will destroy in the proper order. 60 61 ## Next 62 63 You now know how to create, modify, and destroy infrastructure 64 from a local machine. 65 66 Next, we learn how to [use Terraform remotely and the associated benefits](/intro/getting-started/remote.html).