Skip to content

Instantly share code, notes, and snippets.

View damonsmith's full-sized avatar

Damon Smith damonsmith

  • Melbourne, Australia
View GitHub Profile
#!/bin/bash
MAC_ADDRESS=`curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/`
VPC_ID=`curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC_ADDRESS:-1}/vpc-id`
INSTANCE_ID=`curl http://169.254.169.254/latest/meta-data/instance-id`
REGION=`curl http://169.254.169.254/latest/dynamic/instance-identity/document|grep region|awk -F\" '{print $4}'`
TAG_KEY="Reach"
TAG_VALUE="private"
ROUTE_TABLES=`aws ec2 describe-route-tables --filters "Name=tag:$TAG_KEY,Values=$TAG_VALUE" --region $REGION --output text | grep ROUTETABLES | grep $VPC_ID | awk '{print $3}'`
for ROUTE_TABLE in $ROUTE_TABLES
do