You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# See "Destroying Resources" section below for detailed instructions
885
+
./scripts/pre-destroy-cleanup.sh # Run first to clean up blocking resources
886
+
terraform destroy # Then destroy infrastructure
887
+
```
888
+
889
+
## Destroying Resources
890
+
891
+
Before running `terraform destroy`, you must run the pre-destroy cleanup script to remove resources that may block deletion:
892
+
893
+
```bash
894
+
cd terraform/aws-ecs
895
+
896
+
# Step 1: Run pre-destroy cleanup
897
+
./scripts/pre-destroy-cleanup.sh
898
+
899
+
# Step 2: Destroy infrastructure
885
900
terraform destroy
886
901
```
887
902
903
+
### Why Pre-Destroy Cleanup is Required
904
+
905
+
Terraform destroy may fail due to:
906
+
-**ECS Services**: Services must be scaled to 0 and deleted before clusters can be removed
907
+
-**Service Discovery Namespaces**: Must delete services within namespaces before deleting namespaces
908
+
-**ECS Cluster Capacity Providers**: Clusters with active capacity providers cannot be deleted
909
+
-**Secrets Manager Secrets**: Deleted secrets are scheduled for deletion (7-30 days) and block recreation with the same name
910
+
911
+
**Note:** ECR repositories are intentionally NOT deleted by the pre-destroy cleanup script. Container images are preserved to avoid expensive rebuilds when redeploying. See the "ECR Repository Cleanup (Optional)" section below for manual deletion commands.
912
+
913
+
### Manual Cleanup Commands
914
+
915
+
If `terraform destroy` fails, you may need to run these commands manually:
ECR repositories are intentionally NOT deleted by the pre-destroy cleanup script to preserve container images and avoid expensive rebuilds when redeploying. If you want to completely remove all resources including ECR repositories, run these commands manually:
973
+
974
+
```bash
975
+
export AWS_REGION=us-east-1
976
+
977
+
# Delete all ECR repositories (WARNING: This deletes all container images!)
0 commit comments