RunningDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/mcamacho97/terraform-mean-stack-aws/llms.txt
Use this file to discover all available pages before exploring further.
terraform destroy removes every AWS resource that Terraform created for this project in a single, coordinated operation. Terraform reads the current state file, builds a dependency graph of all managed resources, and tears them down in the correct reverse order. This includes the EC2 instances, load balancer, networking components, and IAM resources — the full stack is gone within a few minutes. Because this operation is irreversible for any data stored on those instances, take a moment to complete the pre-destroy checklist before proceeding.
Pre-Destroy Checklist
Export any MongoDB data you need
The MongoDB instance has no automated backup. If you have stored data you want to keep, export it before destroying:
Back up the SSH key
The
keys/<project_name>.pem file is written by a local_file Terraform resource, which means terraform destroy will delete it from disk. Back it up to a safe location before running destroy:Run the Destroy Command
yes and press Enter. The operation typically takes 3–5 minutes, with the NAT Gateway and ALB taking the longest to deprovision.
To skip the confirmation prompt in CI pipelines or scripted workflows:
What Gets Destroyed
All resources managed by this Terraform project are removed, including:Compute
- EC2 instance:
node-1 - EC2 instance:
node-2 - EC2 instance:
mongodb - AWS Key Pair (
<project_name>-key) - Local
keys/<project_name>.pemfile
Load Balancer
- Application Load Balancer
- Target group
- HTTP listener
- Target group attachments
Networking
- VPC
- Public subnets (×2)
- Private subnet
- Internet Gateway
- NAT Gateway
- Elastic IP (NAT)
- Route tables and associations
Security & IAM
- Security groups (ALB, Node, MongoDB)
- IAM role (
<project_name>-ec2-role) - IAM policy attachment (SSM)
- IAM instance profile
What Is NOT Destroyed
| Resource | Reason |
|---|---|
| S3 state bucket | Created outside this project; not in Terraform state |
Partial Destroy
If you want to tear down only a specific module without removing the entire stack, use the-target flag:
Partial destroys can leave the stack in an inconsistent state — for example, destroying the ALB while Node instances remain running. Use targeted destroy only for debugging or cost-saving experiments, not as a routine workflow.
Re-Deploying After Destroy
Onceterraform destroy completes, the state file is empty and you can provision a completely fresh stack with:
keys/<project_name>.pem. All IP addresses, DNS names, and instance IDs will differ from the previous deployment.