-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaws_routes
More file actions
executable file
·32 lines (27 loc) · 818 Bytes
/
aws_routes
File metadata and controls
executable file
·32 lines (27 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
conf_file=~/etc/aws_routes.conf
destinations="kodify"
route_kodify="dev tun0 scope link "
profiles_kodify="
paysites us-east-1
paysites us-east-2
"
[ -f $conf_file ] && source $conf_file
add_route(){
ip=$1
route=$2
full_route="$ip $route"
ip route | grep -qx "$full_route" || sudo ip route add $full_route
}
for destination in $destinations; do
dr=route_${destination}
dp=profiles_${destination}
route="${!dr}"
profiles=${!dp}
echo "$profiles" | xargs -n2 | while read profile region; do
echo "Adding route to $destination - $profile $region"
aws --region $region --profile $profile ec2 describe-instances| jq -r '.Reservations[].Instances[].PublicIpAddress' | while read ip; do
add_route $ip "$route"
done
done
done