Skip to content

Commit

Permalink
unused aws instace and vpcs cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: shiva kumar <shivaku@nvidia.com>
  • Loading branch information
shivakunv committed Dec 17, 2024
1 parent a335eb5 commit 5fbb2b9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/awsvpcscleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ route_tables=$(aws ec2 describe-route-tables \
--output text | tr -d '\r' | tr '\n' ' ')
for rt in $route_tables; do
echo "Deleting route table: $rt"
# Check if this is the main route table
is_main=$(aws ec2 describe-route-tables \
--route-table-ids "$rt" \
--query "RouteTables[0].Associations[?Main==true]" \
--output text | tr -d '\r' | tr '\n' ' ')
if [ -n "$is_main" ]; then
echo "Skipping main route table: $rt"
continue
fi
associations=$(aws ec2 describe-route-tables \
--route-table-ids "$rt" \
--query "RouteTables[0].Associations[].RouteTableAssociationId" \
Expand Down

0 comments on commit 5fbb2b9

Please sign in to comment.