We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2a07703 commit 0c9873bCopy full SHA for 0c9873b
scripts/awsvpcscleanup.sh
@@ -47,7 +47,14 @@ route_tables=$(aws ec2 describe-route-tables \
47
--output text | tr -d '\r' | tr '\n' ' ')
48
for rt in $route_tables; do
49
echo "Deleting route table: $rt"
50
- aws ec2 disassociate-route-table --association-id "$rt"
+ associations=$(aws ec2 describe-route-tables \
51
+ --route-table-ids "$rt" \
52
+ --query "RouteTables[0].Associations[].RouteTableAssociationId" \
53
+ --output text | tr -d '\r' | tr '\n' ' ')
54
+ for assoc in $associations; do
55
+ echo "Disassociating route table association: $assoc"
56
+ aws ec2 disassociate-route-table --association-id "$assoc"
57
+ done
58
aws ec2 delete-route-table --route-table-id "$rt"
59
done
60
0 commit comments