Mappru
VPC Route TablesManage VPC route tables and routes as reviewable Ruby code
- Manages
- Amazon VPC Route Tables
- Language
- Ruby
- Package
- mappru
- CLI
- mappru
- Config file
- Routetable
vpc "vpc-12345678" do
route_table "foo-rt" do
subnets "subnet-12345678"
route destination_cidr_block: "0.0.0.0/0", gateway_id: "igw-12345678"
route destination_cidr_block: "192.168.100.101/32", network_interface_id: "eni-12345678"
route destination_cidr_block: "192.168.100.200/32", ignore: true
end
end
Mappru is a Ruby command-line tool that manages Amazon VPC route tables as code. It exports your route tables, routes, and subnet associations into one file called a Routetable. You review each change in Git, dry-run it, then apply it idempotently.
What is Mappru?
Mappru is a Ruby command-line tool in the codenize-tools family. It manages VPC route tables as code. You describe the route tables you want in one file, and Mappru updates the VPC to match. It follows the same codenization pattern as the rest of the family.
Routing is some of the riskiest config in a VPC. A wrong default route or a deleted peering route can take a whole environment offline. Yet people edit route tables by hand during incidents and never write it down. Mappru makes the routing layer plain text. Each route table declares:
- Routes - a destination CIDR plus the gateway, NAT, or interface it points to.
- Subnet associations - which subnets use the table.
- Ignored routes - entries left for other systems to manage.
Every route now lives in Git, so a change is a diff a colleague can review before it hits the network. Mappru rounds out the VPC layer alongside Piculet for security groups.
- Manages VPC route tables, their routes, and subnet associations.
- The whole routing layer lives in one Ruby DSL file, the Routetable.
- Mark a route
ignore: trueto leave appliance-managed entries alone. - Scope a run by
--vpc-idor--rt-nameto keep blast radius small. - A dry-run shows every route change first; the apply is idempotent.
- Rounds out the VPC layer with Eipmap for Elastic IPs.
Install and run Mappru
Install
Install the mappru gem (Ruby required).
$ gem install mappruExport current state
Pull the live VPC Route Tables configuration into a Routetable.
$ mappru -e -o RoutetableDry-run, then apply
Preview the diff, then apply the change for real.
$ mappru -a --dry-runMappru runs the export, review, apply loop on the part of AWS where mistakes hurt most. Begin in export mode (the -e flag) to pull the current route tables, scoping with --vpc-id if needed, and commit the Routetable to Git.
Every routing change is then a pull request. Edit the file, run the apply with --dry-run, and include the diff so it is clear which routes will be created, replaced, or deleted. After approval, apply for real. The apply is idempotent. Because people also edit routes by hand during incidents, a scheduled dry-run doubles as drift detection: any emergency console change shows up as a diff to codify or revert.
Read the dry-run twice before applying to a production VPC. A single wrong default route can black-hole an entire subnet, so treat routing diffs with extra care.
What Mappru can do
Routes and associations per VPC
Route tables sit inside vpc blocks with their subnet associations and routes. Internet gateway, NAT, and interface targets all read in one file.
Ignore flag for external routes
A route marked ignore: true is left untouched. Routes managed by appliances or controllers can coexist with codenized ones.
Export the current routing state
Export mode dumps existing route tables into the DSL. Adopting Mappru on a long-lived VPC starts from reality, not a blank file.
Dry-run before touching the network
The dry-run prints the exact routes and associations that would change. That matters here more than almost anywhere, since routing mistakes cause outages.
Scoped runs by VPC or table
The --vpc-id and --rt-name options take regexes to limit a run to specific VPCs or tables. Blast radius stays small in shared accounts.
Idempotent apply and split export
Re-running the apply makes no duplicate changes. The --split option writes each definition to its own file for cleaner reviews.
| DSL key | Routes traffic to |
|---|---|
gateway_id | An internet gateway or virtual private gateway |
nat_gateway_id | A NAT gateway for outbound-only access |
network_interface_id | A specific elastic network interface |
vpc_peering_connection_id | A peered VPC |
ignore: true | Nothing; Mappru leaves the route alone |
When teams reach for Mappru
Document routing for multi-tier VPCs
Public, private, and database subnets each carry different default and peering routes. A committed Routetable is living documentation, and unlike a wiki diagram it cannot silently go stale.
Review peering and NAT changes
Adding a peering route or switching a subnet from an internet gateway to a NAT gateway is a one-line change. The pull request and dry-run give it real review.
Coexist with dynamic routing appliances
VPN or firewall appliances sometimes manage their own routes. Marking those ignore: true lets Mappru own the static routes and leave the rest, avoiding fights between automation systems.