Teardown
Destroy the Infrastructure
Section titled “Destroy the Infrastructure”When you are finished exploring the demo, remove all provisioned resources by running terraform destroy. This tears down the Express Gateway Service
The aws_ecs_express_gateway_service Terraform resource that provisions an ECS service with managed ALB, auto scaling, and simplified configuration for HTTP/HTTPS web applications and APIs. , the , networking components, IAM roles, and the ECS cluster in the correct dependency order.
terraform destroyTerraform prompts for confirmation before proceeding. Type yes to confirm. The destroy operation removes resources in reverse dependency order — the Express Gateway Service and its managed ALB are removed first, followed by IAM roles, security groups, subnets, and the VPC
Virtual Private Cloud — an isolated virtual network within AWS where resources are deployed. .
Verify Resource Removal
Section titled “Verify Resource Removal”After terraform destroy completes, confirm Terraform no longer tracks any resources:
terraform state listThe command should produce no output. If any resources are listed, run terraform destroy again to remove them.
Troubleshooting Destroy Failures
Section titled “Troubleshooting Destroy Failures”If terraform destroy fails or hangs, common causes include:
| Symptom | Cause | Resolution |
|---|---|---|
| Timeout waiting for ALB deletion | Active connections draining | Wait for drain to complete or manually deregister targets |
| VPC deletion fails | Dependent resources still exist (ENIs, security group references) | Remove dependent resources first, then retry destroy |
| IAM role deletion fails | Role still attached to running tasks | Stop all tasks in the cluster, then retry destroy |