Fix AWS route discovery

This commit is contained in:
Ivan Ilves 2018-01-29 18:49:55 +01:00
parent 0f2c5649f2
commit 44b7e30621
3 changed files with 9 additions and 1 deletions

View File

@ -10,7 +10,7 @@ fi
export AWS_PROFILE=$(echo ${1} | awk -F"." '{print $2}')
VPC_URL='http://169.254.169.254/latest/meta-data/network/interfaces/macs/$(/sbin/ip link show dev eth0 | grep link/ether | awk '"'"'{print $2}'"'"')/vpc-id'
VPC_ID=$(ssh ${1} curl -s \"${VPC_URL}\")
VPC_ID=$(ssh ${SSH_PRIVATE_KEY_OPTS} ${SSH_PORT_OPTS} ${SSH_EXTRA_OPTS} ${1} curl -s \"${VPC_URL}\")
if [[ ${?} -eq 0 && -n "${VPC_ID}" ]]; then
FILTER_PARAMS="--filters Name=vpc-id,Values=${VPC_ID}"
fi

View File

@ -7,4 +7,9 @@ if [[ -f discover-routes ]]; then
echo "!!! Rewriting stale 'discover-routes' script"
cp discover-routes.aws.example discover-routes
fi
if [[ "$(shasum discover-routes | cut -f1 -d' ')" == "fce86b790248b5c494c360607d27243768f71ec8" ]]; then
echo "!!! Rewriting buggy 'discover-routes' script"
cp discover-routes.aws.example discover-routes
fi
fi

View File

@ -113,6 +113,9 @@ if [[ ${#} -gt 0 ]]; then
declare -r NETWORKS=${@}
elif [[ -x ./discover-routes && ! ${NO_ROUTE_DISCOVERY} ]]; then
if [[ ${USE_ROUTE_CACHE} != true ]]; then
export SSH_PRIVATE_KEY_OPTS
export SSH_PORT_OPTS
export SSH_EXTRA_OPTS
declare -r NETWORKS=$(./discover-routes ${SSH_SERVER} | grep "^ROUTE:" | sed 's/.*://')
echo "${NETWORKS}" >"${ROUTE_CACHE_FILE}"
else