Networking Module
Overview
The Networking Module creates a secure, isolated network infrastructure for the Artos platform. It establishes a Virtual Private Cloud (VPC) with private subnets for application workloads, isolated database subnets, comprehensive security groups, and VPC endpoints for accessing AWS services without internet connectivity. The architecture supports both new VPC creation and integration with existing VPCs.Key Features
- Private Architecture: All workloads run in private subnets with no direct internet access
- Network Isolation: Separate subnets for applications, databases, and network tiers
- Security Groups: Fine-grained traffic control between components
- VPC Endpoints: Private connectivity to AWS services (S3, ECR, Secrets Manager, etc.)
- Flow Logging: Network traffic monitoring and audit trails
- Flexible Deployment: Support for new VPC creation or existing VPC integration
Network Architecture
VPC Configuration
The VPC provides the isolated network boundary for all Artos resources. Default CIDR:10.0.0.0/16 (65,536 IP addresses)
Key Settings:
- DNS Hostnames: Enabled (required for EKS and VPC endpoints)
- DNS Support: Enabled (enables DNS resolution within VPC)
vpc_id is provided, the module:
- Creates only the required subnets (if not provided)
- Integrates with existing networking infrastructure
Subnet Design
The module creates three types of subnets distributed across availability zones for high availability.1. Private Subnets
Purpose: Host EKS worker nodes, application pods, and internal services. Default CIDRs:10.0.10.0/24(254 IPs per subnet)10.0.20.0/24
- No public IP assignment
- No direct internet access
- Traffic routed within VPC or through VPC endpoints
- Used for EKS control plane and worker nodes
- EKS worker nodes
- Application pods (backend API, Celery workers)
- Internal load balancers
- Bastion hosts
2. Database Subnets
Purpose: Completely isolated subnets for RDS databases. Default CIDRs:10.0.100.0/2410.0.200.0/24
- Fully isolated from internet
- Only accessible from EKS nodes via security groups
- Separate route table with no routes (isolated)
- Used exclusively for database instances
- RDS PostgreSQL instances
- Database replicas
- Read replicas (if configured)
Route Tables
Route tables control how traffic flows between subnets and external networks.Private Route Table
Associated With: Private subnets Routes:- Local VPC traffic only (automatic)
- No internet gateway route (no internet access)
- Enterprise connectivity via VPC peering or VPN (configured separately)
Database Route Table
Associated With: Database subnets Routes:- Local VPC traffic only (automatic)
- No other routes (maximum isolation)
Security Groups
Security groups act as virtual firewalls controlling inbound and outbound traffic for resources.1. EKS Cluster Security Group
Attached To: EKS control plane Ingress Rules:
Egress Rules:
- All traffic:
0.0.0.0/0(required for cluster operations and AWS API calls)
2. EKS Nodes Security Group
Attached To: EKS worker nodes (EC2 instances) Ingress Rules:
Egress Rules:
- All traffic to VPC CIDR (allows communication within VPC)
Port 10250: The kubelet API port is critical for Kubernetes operations. The control plane uses this port to execute commands on nodes, collect metrics, and manage pod lifecycle.
3. RDS Security Group
Attached To: RDS database instances Ingress Rules:
Egress Rules:
- All traffic to VPC CIDR
4. ALB Security Group (Internal)
Attached To: Internal Application Load Balancer Ingress Rules:
Egress Rules:
- All traffic:
0.0.0.0/0(ALB needs to reach target pods)
5. Frontend ALB Security Group
Attached To: Frontend Application Load Balancer Ingress Rules:
Egress Rules:
- All traffic:
0.0.0.0/0(ALB needs to reach target pods)
6. VPC Endpoints Security Group
Attached To: All VPC interface endpoints Ingress Rules:
Egress Rules:
- All traffic:
0.0.0.0/0
VPC Endpoints
VPC endpoints enable private connectivity to AWS services without requiring internet access or NAT gateways.Gateway Endpoints
S3 Endpoint
Type: Gateway endpoint (routes added to route tables) Service:com.amazonaws.{region}.s3
Purpose: Private access to S3 buckets
Use Cases:
- Application file storage and retrieval
- ECR image layer storage (ECR uses S3 backend)
- Log archival and backups
- Static asset delivery
Interface Endpoints
Interface endpoints create Elastic Network Interfaces (ENIs) in your subnets with private IP addresses.ECR Endpoints
Services:com.amazonaws.{region}.ecr.dkr- Docker Registry APIcom.amazonaws.{region}.ecr.api- ECR control plane API
- EKS nodes pulling container images
- CI/CD pipelines accessing ECR
- Image scanning and vulnerability checks
ecr.dkr: Docker daemon communicates with ECR registryecr.api: ECR control plane operations (list images, get authorization tokens)
EC2 Endpoint
Service:com.amazonaws.{region}.ec2
Purpose: EC2 API operations from private subnets
Use Cases:
- EKS node bootstrap scripts calling EC2 APIs
- Auto Scaling Group operations
- ENI attachment and management
- Instance metadata access
STS Endpoint
Service:com.amazonaws.{region}.sts
Purpose: AWS Security Token Service for IAM role assumption
Use Cases:
- IRSA (IAM Roles for Service Accounts) in EKS
- Pod service accounts assuming IAM roles
- Temporary credential generation
- Cross-account access
EKS Endpoint
Service:com.amazonaws.{region}.eks
Purpose: EKS control plane API access
Use Cases:
- kubectl commands from bastion host
- EKS cluster management operations
- eksctl operations
- Cluster configuration updates
Elastic Load Balancing Endpoint
Service:com.amazonaws.{region}.elasticloadbalancing
Purpose: Load balancer management APIs
Use Cases:
- AWS Load Balancer Controller creating ALBs
- Target group registration
- Health check configuration
- Listener rule management
Secrets Manager Endpoint
Service:com.amazonaws.{region}.secretsmanager
Purpose: Retrieve secrets from AWS Secrets Manager
Use Cases:
- Application pods fetching database credentials
- API key retrieval
- Configuration secret access
- Certificate management
SSM Endpoints
Services:com.amazonaws.{region}.ssm- Systems Managercom.amazonaws.{region}.ssmmessages- Session Manager messagingcom.amazonaws.{region}.ec2messages- SSM Agent communication
- SSH-less bastion host access
- Node troubleshooting via Session Manager
- Secure remote command execution
- Session logging and auditing
Private DNS
All interface endpoints have Private DNS enabled, which means:- AWS service calls automatically resolve to the VPC endpoint IP
- No application code changes required
- Services use standard AWS SDK endpoints
- Traffic stays within VPC
VPC Flow Logs
Flow logs capture network traffic metadata for security analysis and troubleshooting. Log Destination: CloudWatch Logs group/vpc/{vpc_id}/flow-logs
Retention: 14 days
Traffic Captured: ALL (accepted and rejected traffic)
Aggregation Interval: 60 seconds
Logged Fields:
- Source and destination IP addresses
- Source and destination ports
- Protocol
- Number of packets
- Number of bytes
- Action (ACCEPT or REJECT)
- Timestamp
- Security incident investigation
- Network troubleshooting
- Compliance auditing
- Traffic pattern analysis
- Unusual traffic detection
- Source:
10.0.10.50:45234(EKS node) - Destination:
10.0.100.20:5432(RDS database) - Protocol: 6 (TCP)
- Action: ACCEPT (security groups allowed)
Module Configuration
Basic Configuration (New VPC)
Configuration with Existing VPC
Production Configuration
Development Configuration
Security Best Practices
1. Network Segmentation
The module implements defense-in-depth through multiple isolation layers: Subnet Isolation:- Application workloads in private subnets
- Databases in isolated database subnets
- No direct communication between tiers without security group rules
- Database subnets have no routes (local traffic only)
- Private subnets have no internet gateway route
- Each tier has dedicated route table
2. Security Group Rules
Follow the principle of least privilege: Good Practices:- Specific port ranges instead of “all ports”
- Reference security groups instead of CIDR blocks when possible
- Document each rule’s purpose in descriptions
- Regular audit of unused rules
3. VPC Endpoint Security
VPC endpoints should be protected:- Dedicated security group for endpoints
- Restrict access to VPC CIDR only
- Enable Private DNS for transparent access
- Monitor endpoint usage via VPC Flow Logs
4. Flow Log Analysis
Regularly analyze VPC Flow Logs for: Security Threats:- Rejected traffic patterns (potential attacks)
- Unusual source IPs
- Port scanning attempts
- Data exfiltration indicators
5. CIDR Planning
Plan IP address space carefully: Recommendations:- Use RFC 1918 private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
- Leave room for growth (don’t use /24 for entire VPC)
- Avoid overlapping CIDRs with corporate networks
- Reserve ranges for future subnets
Troubleshooting
Cannot Access AWS Services from Pods
Symptoms: Pods fail to access S3, ECR, Secrets Manager, etc. Troubleshooting:- Verify VPC Endpoints are Created:
- Check Endpoint Security Group:
- Verify Private DNS is Enabled:
- Test from Pod:
RDS Connection Failures
Symptoms: Applications cannot connect to RDS database. Troubleshooting:- Verify Security Group Rules:
- Check if Source is EKS Nodes Security Group:
- Test Connectivity from Pod:
- Check VPC Flow Logs:
Bastion Cannot Access EKS API
Symptoms: kubectl commands fail from bastion host. Solutions:- Verify Bastion in Additional Security Groups:
- Check EKS Security Group Ingress:
- Verify EKS VPC Endpoint:
Related Modules
- EKS Module - Uses VPC and subnets for cluster deployment
- RDS Module - Uses database subnets and security groups
- Bastion Module - Deployed in private subnets with VPC endpoint access
- IAM Module - IRSA requires STS VPC endpoint
Module Maintenance: This module is compatible with Terraform 1.0+ and AWS Provider 5.x. VPC endpoints and security groups follow AWS best practices for private cloud deployments. Review and adjust CIDR blocks based on your network architecture requirements before deployment.