Interview Prep/Terraform/Authentication and Cloud API Errors

Destroying a VPC hangs, then fails with `DependencyViolation: The subnet 'subnet-0abc' has dependencies and cannot be deleted.`

IntermediateTroubleshootingAuthentication and Cloud API Errors
Answer

Likely causes → Resources not managed by this state still use the subnet: ENIs from Lambda in VPC, load balancers created by the Kubernetes controller, EKS nodes, VPC endpoints from another stack.

Diagnose →

aws ec2 describe-network-interfaces --filters Name=subnet-id,Values=subnet-0abc \
  --query 'NetworkInterfaces[].[NetworkInterfaceId,InterfaceType,Description]' --output table

Fix → Delete the dependents first (Kubernetes Service type=LoadBalancer/Ingress before cluster teardown; wait for Lambda hyperplane ENIs to be released, which can take up to around 40 minutes), then re-run destroy.

Prevent → Destroy in reverse stack order (workloads → cluster → network) and tag controller-created resources.

All Terraform questions

More on Authentication and Cloud API Errors