Route tables and route targets

Routing is one of the most important topics in network engineering. It is worth looking at it more closely. We already saw that we had an implicit router and the main routing table when we created the VPC. From the last example, we created an internet gateway, a custom routing table with a default route pointing to the internet gateway, and associated the custom routing table with a subnet.

The concept of the route target is where VPC is a bit different than traditional networking. In summary: 

  • Each VPC has an implicit router
  • Each VPC has the main routing table with the local route populated
  • You can create custom-routing tables
  • Each subnet can follow a custom-routing table or the default main routing table
  • The route table route target can be an internet gateway, NAT gateway, VPC peers, and so on

We can use Boto3 to look at the custom route tables and association with the subnets: 

$ cat Chapter9_2_query_route_tables.py
#!/usr/bin/env python3

import json, boto3

region = 'us-east-1'
vpc_name = 'mastering_python_networking_demo'

ec2 = boto3.resource('ec2', region_name=region)
client = boto3.client('ec2')

response = client.describe_route_tables()
print(json.dumps(response['RouteTables'][0], sort_keys=True, indent=4))

We only have one custom route table: 

$ python3 Chapter9_2_query_route_tables.py
{
"Associations": [
{
....
}
],
"PropagatingVgws": [],
"RouteTableId": "rtb-6bee5514",
"Routes": [
{
"DestinationCidrBlock": "10.0.0.0/16",
"GatewayId": "local",
"Origin": "CreateRouteTable",
"State": "active"
},
{
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": "igw-...",
"Origin": "CreateRoute",
"State": "active"
}
],
"Tags": [
{
"Key": "Name",
"Value": "public_internet_gateway"
}
],
"VpcId": "vpc-..."
}

Creating the subnets are straight forward by clicking on the left subnet section and follow the on-screen instruction. For our purpose, we will create three subnets, 10.0.0.0/24 public subnet, 10.0.1.0/24, and 10.0.2.0/24 private subnets.  

We now have a working VPC with three subnets: one public and two private. So far, we have used the AWS CLI and Boto3 library to interact with AWS VPC. Let's take a look at another automation tool, CloudFormation

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.220.14