Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0c9873b

Browse files
committedDec 17, 2024··
unused aws instace and vpcs cleanup
Signed-off-by: shiva kumar <shivaku@nvidia.com>
1 parent 2a07703 commit 0c9873b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎scripts/awsvpcscleanup.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ route_tables=$(aws ec2 describe-route-tables \
4747
--output text | tr -d '\r' | tr '\n' ' ')
4848
for rt in $route_tables; do
4949
echo "Deleting route table: $rt"
50-
aws ec2 disassociate-route-table --association-id "$rt"
50+
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
5158
aws ec2 delete-route-table --route-table-id "$rt"
5259
done
5360

0 commit comments

Comments
 (0)
Please sign in to comment.