Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.33 KB

5. Destroy infrastructure.md

File metadata and controls

38 lines (25 loc) · 1.33 KB

Destroying Infrastructure

Once infrastructure is no longer needed, use terraform destroy to terminate resources:

terraform destroy

Terraform will display an execution plan indicating which resources will be destroyed. Confirm with yes to proceed.

Example Output

Terraform will perform the following actions:

  # aws_instance.app_server will be destroyed
  - resource "aws_instance" "app_server" {
      - ami                          = "ami-08d70e59c07c61a3a" -> null
      - arn                          = "arn:aws:ec2:us-west-2:561656980159:instance/i-0fd4a35969bd21710" -> null
      ...
  }

Plan: 0 to add, 0 to change, 1 to destroy.

Do you really want to destroy all resources? Only 'yes' will be accepted to confirm.

  Enter a value: yes

aws_instance.app_server: Destroying... [id=i-0fd4a35969bd21710]
aws_instance.app_server: Still destroying... [id=i-0fd4a35969bd21710, 10s elapsed]
aws_instance.app_server: Destruction complete after 31s

Destroy complete! Resources: 1 destroyed.

Terraform determines the order of resource destruction, respecting dependencies.

Terraform simplifies infrastructure management by enabling you to create, modify, and destroy resources using a consistent workflow. Use best practices like version control and remote backends to manage configurations and state securely.