github.com/maheshbr/terraform@v0.3.1-0.20141020033300-deec7194a3ea/website/source/intro/getting-started/destroy.html.md (about) 1 --- 2 layout: "intro" 3 page_title: "Destroy Infrastructure" 4 sidebar_current: "gettingstarted-destroy" 5 --- 6 7 # Destroy Infrastructure 8 9 We've now seen how to build and change infrastructure. Before we 10 move on to creating multiple resources and showing resource 11 dependencies, we're going to go over how to completely destroy 12 the Terraform-managed infrastructure. 13 14 Destroying your infrastructure is a rare event in production 15 environments. But if you're using Terraform to spin up multiple 16 environments such as development, test, QA environments, then 17 destroying is a useful action. 18 19 ## Plan 20 21 Before destroying our infrastructure, we can use the plan command 22 to see what resources Terraform will destroy. 23 24 ``` 25 $ terraform plan -destroy 26 ... 27 28 - aws_instance.example 29 ``` 30 31 With the `-destroy` flag, we're asking Terraform to plan a destroy, 32 where all resources under Terraform management are destroyed. You can 33 use this output to verify exactly what resources Terraform is managing 34 and will destroy. 35 36 ## Destroy 37 38 Let's destroy the infrastructure now: 39 40 ``` 41 $ terraform destroy 42 aws_instance.example: Destroying... 43 44 Apply complete! Resources: 0 added, 0 changed, 1 destroyed. 45 46 ... 47 ``` 48 49 The `terraform destroy` command should ask you to verify that you 50 really want to destroy the infrastructure. Terraform only accepts the 51 literal "yes" as an answer as a safety mechanism. Once entered, Terraform 52 will go through and destroy the infrastructure. 53 54 Just like with `apply`, Terraform is smart enough to determine what order 55 things should be destroyed. In our case, we only had one resource, so there 56 wasn't any ordering necessary. But in more complicated cases with multiple 57 resources, Terraform will destroy in the proper order. 58 59 ## Next 60 61 You now know how to create, modify, and destroy infrastructure. 62 With these building blocks, you can effectively experiment with 63 any part of Terraform. 64 65 Next, we move on to features that make Terraform configurations 66 slightly more useful: [variables, resource dependencies, provisioning, 67 and more](/intro/getting-started/dependencies.html).