Skip to content

Commit 7462369

Browse files
authored
remove eks resources before vpc (#1030)
Signed-off-by: Manabu McCloskey <manabu.mccloskey@gmail.com>
1 parent 6d3f6f5 commit 7462369

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

infra/terraform/cleanup.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ if [ ${#targets[@]} -gt 0 ]; then
8181
fi
8282

8383

84+
## Destroy EKS resources before VPC to ensure NAT gateway and VPC endpoints
85+
## remain available while nodes drain
86+
echo "Destroying EKS resources first (preserving VPC for pod cleanup)..."
87+
destroy_output=$($TERRAFORM_COMMAND -var="region=$REGION" -target=module.eks 2>&1 | tee /dev/tty)
88+
if [[ ${PIPESTATUS[0]} -eq 0 && $destroy_output == *"Destroy complete"* ]]; then
89+
echo "SUCCESS: EKS resources destroyed"
90+
else
91+
echo "FAILED: EKS destroy failed"
92+
exit 1
93+
fi
94+
8495
## Final destroy to catch any remaining resources
8596
echo "Destroying remaining resources..."
8697
destroy_output=$($TERRAFORM_COMMAND -var="region=$REGION" 2>&1 | tee /dev/tty)

0 commit comments

Comments
 (0)