Python script to clone an existing VPC route table. Script output is a series of AWS CLI calls to create the route table and assign routes.
Update AWS_TARGET_REGION
and SOURCE_ROUTE_TABLE_ID
to suit.
Note: does not currently support NAT Gateways routes due to Boto 2 API limitation.
$ ./clone-route-table.py
# output generated...
routeTableID=$(aws ec2 create-route-table --region REGION --vpc-id vpc-XXXXXXXX --output text | grep "^ROUTETABLE" | cut -f2)
echo "Route table: $routeTableID"
aws ec2 create-route --region REGION --route-table-id $routeTableID --destination-cidr-block 172.60.20.10/32 --gateway-id igw-XXXXXXXX
aws ec2 create-route --region REGION --route-table-id $routeTableID --destination-cidr-block x.x.x.x/24 ----vpc-peering-connection-id pcx-XXXXXXXX
# and so on...