From 5fea301779d1c2d0ee5248a6658e37d724781a2e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 23 Jul 2014 14:42:33 -0700 Subject: [PATCH] website: destroy getting started page --- .../intro/getting-started/destroy.html.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 website/source/intro/getting-started/destroy.html.md diff --git a/website/source/intro/getting-started/destroy.html.md b/website/source/intro/getting-started/destroy.html.md new file mode 100644 index 000000000..1f4ff9a70 --- /dev/null +++ b/website/source/intro/getting-started/destroy.html.md @@ -0,0 +1,68 @@ +--- +layout: "intro" +page_title: "Destroy Infrastructure" +sidebar_current: "gettingstarted-destroy" +--- + +# Destroy Infrastructure + +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. + +Destroying your infrastructure is a rare event in production +environments. But if you're using Terraform to spin up multiple +environments such as development, test, QA environments, then +destroying is a useful action. + +## Plan + +While our infrastructure is simple, viewing the execution plan +of a destroy can be useful to make sure that it is destroying +only the resources you expect. + +To ask Terraform to create an execution plan to destroy all +infrastructure, run the plan command with the `-destroy` flag. + +``` +$ terraform plan -destroy +... + +- aws_instance.example +``` + +The output says that "aws\_instance.example" will be deleted. + +The `-destroy` flag lets you destroy infrastructure without +modifying the configuration. You can also destroy infrastructure +by simply commenting out or deleting the contents of your +configuration, but usually you just want to destroy an instance +of your infrastructure rather than permanently deleting your +configuration as well. The `-destroy` flag is for this case. + +## Apply + +Let's apply the destroy: + +``` +$ terraform apply -destroy +aws_instance.example: Destroying... + +Apply complete! Resources: 0 added, 0 changed, 1 destroyed. + +... +``` + +Done. Terraform destroyed our one instance, and if you run a +`terraform show`, you'll see that the state file is now empty. + +## Next + +You now know how to create, modify, and destroy infrastructure. +With these building blocks, you can effectively experiment with +any part of Terraform. + +Next, we move on to features that make Terraform configurations +slightly more useful: variables, resource dependencies, provisioning, +and more.