Added subnet filtering by VPC ID

This commit is contained in:
Ivan Ilves 2017-02-21 09:36:55 +01:00
parent 525737ae62
commit a27148afce
2 changed files with 8 additions and 2 deletions

View File

@ -9,4 +9,10 @@ fi
export AWS_PROFILE=$(echo ${1} | awk -F"." '{print $2}') export AWS_PROFILE=$(echo ${1} | awk -F"." '{print $2}')
aws ec2 describe-subnets | grep CidrBlock\":\ \"10 | awk -F"\"" '{print $4}' | sort | uniq 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}\")
if [[ ${?} -eq 0 && -n "${VPC_ID}" ]]; then
FILTER_PARAMS="--filters Name=vpc-id,Values=${VPC_ID}"
fi
aws ec2 describe-subnets ${FILTER_PARAMS} | grep CidrBlock\":\ \"10 | awk -F"\"" '{print "ROUTE:"$4}' | sort | uniq

View File

@ -30,7 +30,7 @@ declare -r SSH_SERVER=${1}; shift
if [[ ${#} -gt 0 ]]; then if [[ ${#} -gt 0 ]]; then
declare -r NETWORKS=${@} declare -r NETWORKS=${@}
elif [[ -x ./discover-routes ]]; then elif [[ -x ./discover-routes ]]; then
declare -r NETWORKS=$(./discover-routes ${SSH_SERVER}) declare -r NETWORKS=$(./discover-routes ${SSH_SERVER} | grep "^ROUTE:" | sed 's/.*://')
fi fi
declare -r IP_BASE=192.168.245 declare -r IP_BASE=192.168.245