Q: Deleting a load balancer through Terraform fails because dependent listeners and target groups are still attached. How do you debug this?
Inspect the dependency graph and the cloud-side error to find the resource still in use.
Want to master this scenario in a live sandbox? KodeKloud's HashiCorp Certified Terraform Associate (003) Interactive Labs covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: "Managing infrastructure as code across multiple teams requires disciplined state management and locking. When addressing this question, I walk the interviewer through our production incident runbook: isolating the blast radius, checking diagnostic logs and metrics, and applying a safe fix."
Production Solution & Architecture
Inspect the dependency graph and the cloud-side error to find the resource still in use. Terraform usually infers dependencies from references, but dependencies can be hidden when values are passed as plain strings or created outside the same root module. Add missing references or explicit depends_on where the relationship is real, then rerun the plan. Fix the dependency model instead of repeatedly retrying the same destroy.
- Immediate Triage: Inspect the dependency graph and the cloud-side error to find the resource still in use. Terraf
- Run targeted verification commands before modifying configuration.
- Automate permanent guardrails (CI check, alerts, IaC policy) to prevent recurrence.
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Configuring application keepalive timeouts shorter than the Application Load Balancer idle timeout When backend app keepalive is shorter than the ALB timeout (default 60s), the app closes connections while ALB routes new requests, triggering intermittent 502 errors.
-
Overlooking Target Group health check path misconfigurations when registering new backend services
Pointing health checks to deep authenticated endpoints instead of dedicated
/healthzendpoints leads to false-positive target evictions. - Neglecting cross-zone load balancing configuration on Network Load Balancers (NLB) NLBs route traffic within the receiving Availability Zone by default; without cross-zone balancing enabled, uneven client traffic skews backend target load.
- Failing to inspect ALB access logs via Amazon Athena during intermittent 5xx latency spikes ALB access logs reveal request processing time, target response time, and exact client TLS ciphers necessary to diagnose edge latency anomalies.