Change the cost structure while retaining fallback
Our outbound traffic passed through managed NAT gateways, whose processing charges grew with traffic volume. I adopted alterNAT to move the normal path onto EC2 NAT instances while retaining managed gateways as fallback.
This removes the managed gateway’s per-gigabyte processing charge from traffic that stays on the instance path. EC2, standby gateways, and other applicable network charges remain part of the cost. The trade-off is operating NAT instances and their health checks in exchange for a different cost structure.
Make the failure path part of the design
alterNAT checks connectivity every minute. Failed checks or an instance termination trigger a route change to the managed gateway. A replacement instance restores the instance route during startup. Upstream also supports health-based restoration of a recovered instance through a separate opt-in setting.
The check interval is a detection cadence, not a guarantee of recovery within one minute.
I introduced the system in the main VPCs, then made it an option in the cell platform. The configuration uses ARM instances. It also allocates separate Elastic IPs for the instance and fallback gateway, allowing both egress addresses to be known and allowlisted ahead of a switch.
Remove an unnecessary deployment dependency
The version of alterNAT we adopted required a container image for its failover function. That added a build and registry dependency to infrastructure automation running through pull requests.
I contributed two changes upstream:
- Zip deployment support, PR #44, allowing the function to use the standard Lambda runtime without an image registry.
- Dependency removal, PR #52, replacing
requestswith the standard library and removing the Terraform-time dependency installation step. The function still usesboto3, supplied by the Lambda runtime.
The cell configuration uses that deployment path:
# Selected inputs from the alterNAT module invocation.architecture = "arm64"lambda_package_type = "Zip"create_nat_gateways = trueWhat changed
Normal traffic gained an instance-based egress path with automatic managed-gateway fallback. The integration fit the existing Terraform workflow, and the deployment changes shipped upstream, where they could be maintained and reused beyond our own installation.