In this tutorial, you will completely destroy the Terraform-managed infrastructure you previously created.
»Destroy your infrastructure
Use terraform destroy
to remove infrastructure from your Azure cloud account.
$ terraform destroy
azurerm_resource_group.rg: Refreshing state... [id=/subscriptions/c9ed8610-47a3-4107-a2b2-a322114dfb29/resourceGroups/myTFResourceGroup]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
# azurerm_resource_group.rg will be destroyed
- resource "azurerm_resource_group" "rg" {
- id = "/subscriptions/c9ed8610-47a3-4107-a2b2-a322114dfb29/resourceGroups/myTFResourceGroup" -> null
- location = "westus2" -> null
- name = "myTFResourceGroup" -> null
- tags = {
- "Environment" = "Terraform Getting Started"
- "Team" = "DevOps"
} -> null
}
Plan: 0 to add, 0 to change, 1 to destroy.
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value:
The -
prefix indicates that the instance will be destroyed. As with apply, Terraform shows its execution plan and waits for approval before making any changes.
When prompted, type yes
to execute this plan and destroy the infrastructure.
Just like with apply, Terraform determines the order in which things must be destroyed. In more complicated cases with multiple resources, Terraform will destroy them in a suitable order to respect dependencies, which you will learn more about in the next tutorial.