rvn-aws-network · Latest version: 0.2.2
Dependencies and consumers
Every dependency input can be specified manually to reference existing external infrastructure rather than a Ravion module.Readme
Production-ready AWS VPC with public and private subnets, NAT gateways, and compliance-ready flow logs.Overview
A VPC (Virtual Private Cloud) is the foundational networking layer for your AWS infrastructure. This module creates an isolated virtual network with public and private subnets spanning multiple availability zones, giving you complete control over your networking environment. The VPC module provides:- Public and private subnets across multiple availability zones for high availability
- NAT Gateway options for outbound internet access from private subnets
- VPC Flow Logs for network traffic monitoring and SOC 2 compliance
- VPC Peering to connect with existing VPCs across accounts or regions
Use cases
Subnet types
Public subnets
Public subnets have direct internet access via a free Internet Gateway. Resources in public subnets do not receive public IP addresses automatically; attach public IPs explicitly when needed. Use these for:- Load balancers (ALB, NLB)
- Bastion hosts
- NAT Gateways
Private subnets
Private subnets have no direct internet access. Outbound traffic routes through NAT Gateway(s) when enabled. Use these for:- Application servers (ECS tasks, EKS pods)
- RDS databases
- ElastiCache clusters
- Lambda functions with VPC access
NAT Gateway
NAT Gateway gives your private subnets two things:- Internet access — Resources can reach the internet for updates, API calls, and external services
- Static public IP — All outbound traffic exits through the same IP, so partners can allowlist your IP address
Keeping your IP stable
By default, the module creates a new Elastic IP for each NAT Gateway. If you ever reprovision the VPC, that IP changes. To keep the same IP permanently, create your Elastic IPs separately and pass in the allocation IDs. This way, even if you destroy and recreate the entire VPC, your NAT Gateway will use the same public IP — no need to update partner allowlists or firewall rules.Configuration
VPC Peering
Connect this VPC to existing VPCs for private communication without traversing the internet. Peering supports:- Same-account, same-region: Auto-accepts and configures routes in both directions
- Cross-account or cross-region: Creates the peering request; peer must accept and configure return routes
SOC 2 compliance
Enable Flow Logs to capture network traffic metadata for security auditing. Flow logs record:- Source and destination IP addresses
- Ports and protocols
- Packet and byte counts
- Accept/reject actions
Design decisions
This VPC follows AWS VPC best practices:- Availability zone spread: Subnets are provisioned across up to 3 AZs by default, capped by the AZs available in the selected region and AWS account
- Automatic CIDR allocation: Subnets are /24 blocks carved from your VPC CIDR. With the default
10.0.0.0/16, the first three public subnets get10.0.1.0/24,10.0.2.0/24,10.0.3.0/24and private subnets get10.0.11.0/24,10.0.12.0/24,10.0.13.0/24. - DNS enabled: DNS support and hostnames are enabled for service discovery
- Single route table for public: All public subnets share one route table with an Internet Gateway route
- Per-AZ route tables when HA NAT: Each private subnet gets its own route table pointing to the NAT in its AZ
Learn more
AWS VPC- AWS VPC User Guide — Official documentation
- VPC Design Best Practices — Security recommendations
- NAT Gateway Pricing — Cost breakdown for NAT Gateways
- Plan your VPC — AWS guide to VPC planning
- Building Scalable and Secure Multi-VPC Infrastructure — AWS whitepaper on VPC design patterns
- Availability Zones — Understanding AZ redundancy
Inputs reference
All inputs forrvn-aws-network version 0.2.2. Use the name shown for each field as the input key in module config.
AWS account & region
AWS account.
- Immutable after creation
Region. Recommend anything but us-east-1 as it has the most outages.
- Immutable after creation
VPC config
Name slug. Name prefix for all resources created by this module.
- Default:
<<project.given_id>>-<<environment.given_id>> - Immutable after creation
- Pattern:
^[a-z0-9]([a-z0-9-]{0,34}[a-z0-9])?$— The name must be 1-36 characters, contain only lowercase letters, numbers, and hyphens, and start and end with a letter or number.
VPC CIDR. The IPv4 CIDR block for the VPC.
- Default:
10.0.0.0/16 - Immutable after creation
Subnet pairs. Leave empty to create up to 3 public/private subnet pairs, capped by the availability zones available in the selected region and AWS account.
- Min:
1 - Max:
6
NAT gateway
NAT gateway. Needed if you want to access the internet from within private subnets
- Default:
true
NAT gateway high availability. High availability adds NAT Gateway to every AZ. Otherwise single NAT gateway serves all AZs.
- Default:
false
NAT gateway Elastic IP allocation IDs. A list of pre-allocated Elastic IP allocation IDs (for example from the
networking/eips module) to associate with the NAT Gateway(s). When null
or empty (default), the module allocates new EIPs internally.The list length must match the number of NAT Gateways the module will create:
- 1 when nat_gateway_high_availability_enabled = false
- the resolved subnet pair count when nat_gateway_high_availability_enabled = true
SOC 2
Flow logs. Enable VPC Flow Logs for network traffic monitoring. Required for SOC 2.
- Default:
false
Misc
Tags. A map of tags to assign to all resources. Default tags are
Owner, ProjectGivenId, EnvironmentGivenId, ModuleGivenId, ModuleIdVPC peering
Peering connections. Connect this VPC to other VPCsNOTE: For cross-account or cross-region peerings, this module cannot manage the
peer VPC’s route tables. The owner of the peer VPC is responsible for adding
return routes pointing at the peering connection.
Terraform settings
OpenTofu version override. Override the environment’s default version for this module
Ravion Terraform workspace name. Override Terraform state backend workspace name. Defaults to project + environment + module given ids.
- Immutable after creation
Advanced Terraform variables. Optional raw Terraform variable overrides for advanced module inputs or one-off overrides. Values here override the generated variables above.
- Default:
{}
Terraform execution environment. Override the VPC, subnet, and security group for Terraform runners. Must use the same AWS account as selected above.