⚡ ~/naveed Labs
⚡ Portfolio Home 👤 About Naveed Bio & Credentials 📫 Contact Naveed Get In Touch ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →

What Is the AWS Startup Reference Architecture?

The AWS startup reference architecture is a lean, resilient, production-ready cloud topology designed to bootstrap early-stage SaaS platforms under $100/month. It leverages a dual-AZ VPC, an open-source fck-nat Graviton instance ($3.20/mo vs $65/mo for managed NATs), Amazon ECS Fargate for serverless container orchestration, and Aurora Serverless v2 PostgreSQL for auto-scaling persistence without Kubernetes operational overhead.

Most startups fail not from architectural limitations, but from running out of capital. Over-engineering a Kubernetes cluster (EKS) at Day 1 creates a baseline cost of $150 to $300/month in control plane fees and worker nodes before serving a single paying user. The AWS startup reference architecture eliminates unnecessary fixed expenses while preserving full enterprise-grade security, automated blue/green rolling updates, multi-AZ high availability, and keyless CI/CD.

Ingress & Edge
Public ALB + ACM SSL
Auto-renewing wildcard TLS certificate, automated HTTP-to-HTTPS 301 redirection, and health check routing.
Compute Tier
Amazon ECS Fargate
0.25 vCPU / 0.5 GB RAM containers in private subnets with zero EC2 OS patching or worker node management.
Database Tier
Aurora Serverless v2
PostgreSQL cluster scaling dynamically from 0.5 ACU up to 2.0 ACU in isolated database subnets.
Egress Tier
fck-nat on Graviton
ARM64 t4g.nano instance providing outbound NAT routing for $3.20/mo, eliminating $65/mo AWS NAT Gateway fees.

1 Deploy Minimal 2-AZ VPC with fck-nat ($3.20/mo vs $65/mo)

Standard AWS NAT Gateways cost $32.85/month each plus data processing charges. For early-stage startups, deploying the battle-tested open-source fck-nat AMI on an ARM64 t4g.nano Graviton instance slashes your VPC networking bill to $3.20/month with zero loss in throughput for sub-1 Gbps traffic.

terraform/vpc.tf
module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "5.8.0"

  name = "startup-vpc-prod"
  cidr = "10.0.0.0/16"

  azs              = ["us-east-1a", "us-east-1b"]
  public_subnets   = ["10.0.1.0/24", "10.0.2.0/24"]
  private_subnets  = ["10.0.11.0/24", "10.0.12.0/24"]
  database_subnets = ["10.0.21.0/24", "10.0.22.0/24"]

  # Disable expensive managed AWS NAT Gateways ($65/mo)
  enable_nat_gateway     = false
  single_nat_gateway     = false
  enable_dns_hostnames   = true
  enable_dns_support     = true

  create_database_subnet_group = true

  tags = {
    Environment = "production"
    Terraform   = "true"
    Project     = "startup-blueprint"
  }
}

# Deploy high-performance fck-nat on Graviton ARM64
module "fck_nat" {
  source  = "RaJAbhi/fck-nat/aws"
  version = "1.3.0"

  name               = "startup-fck-nat"
  vpc_id             = module.vpc.vpc_id
  subnet_id          = module.vpc.public_subnets[0]
  instance_type      = "t4g.nano" # ~$3.20/month
  use_cloudwatch_agent = true

  tags = {
    Name = "startup-fck-nat"
  }
}

# Route private subnets through the fck-nat network interface
resource "aws_route" "private_fck_nat" {
  route_table_id         = module.vpc.private_route_table_ids[0]
  destination_cidr_block = "0.0.0.0/0"
  network_interface_id   = module.fck_nat.network_interface_id
}

2 Configure Application Load Balancer with Automated SSL & Redirects

The Application Load Balancer (ALB) handles TLS certificate termination using AWS Certificate Manager (ACM). It automatically redirects all unencrypted HTTP port 80 traffic to HTTPS port 443 with a permanent 301 status code and forwards requests to private ECS tasks.

terraform/alb.tf
resource "aws_lb" "main" {
  name               = "startup-alb-prod"
  internal           = false
  load_balancer_type = "application"
  security_groups    = [aws_security_group.alb.id]
  subnets            = module.vpc.public_subnets

  drop_invalid_header_fields = true
  enable_deletion_protection = false

  tags = {
    Environment = "production"
  }
}

resource "aws_lb_target_group" "app" {
  name        = "startup-tg-prod"
  port        = 8080
  protocol    = "HTTP"
  vpc_id      = module.vpc.vpc_id
  target_type = "ip" # Required for ECS Fargate

  health_check {
    enabled             = true
    path                = "/health"
    port                = "8080"
    matcher             = "200"
    interval            = 30
    timeout             = 5
    healthy_threshold   = 2
    unhealthy_threshold = 3
  }
}

# HTTP to HTTPS redirect
resource "aws_lb_listener" "http" {
  load_balancer_arn = aws_lb.main.arn
  port              = "80"
  protocol          = "HTTP"

  default_action {
    type = "redirect"
    redirect {
      port        = "443"
      protocol    = "HTTPS"
      status_code = "HTTP_301"
    }
  }
}

# HTTPS listener with ACM certificate
resource "aws_lb_listener" "https" {
  load_balancer_arn = aws_lb.main.arn
  port              = "443"
  protocol          = "HTTPS"
  ssl_policy        = "ELBSecurityPolicy-TLS13-1-2-2021-06"
  certificate_arn   = aws_acm_certificate.cert.arn

  default_action {
    type             = "forward"
    target_group_arn = aws_lb_target_group.app.arn
  }
}

3 Deploy Amazon ECS Fargate Cluster & Service (0.25 vCPU, 0.5 GB RAM)

By sizing your initial container tasks at 0.25 vCPU and 0.5 GB memory, a single continuous Fargate task costs only ~$9/month. Running two tasks across separate Availability Zones provides true high availability for under $19/month without any EC2 instance management.

terraform/ecs.tf
resource "aws_ecs_cluster" "main" {
  name = "startup-ecs-cluster"

  setting {
    name  = "containerInsights"
    value = "enabled"
  }
}

resource "aws_ecs_task_definition" "app" {
  family                   = "startup-api"
  network_mode             = "awsvpc"
  requires_compatibilities = ["FARGATE"]
  cpu                      = "256" # 0.25 vCPU
  memory                   = "512" # 0.5 GB RAM
  execution_role_arn       = aws_iam_role.ecs_execution.arn
  task_role_arn            = aws_iam_role.ecs_task.arn

  container_definitions = jsonencode([
    {
      name      = "api"
      image     = "${aws_ecr_repository.app.repository_url}:latest"
      essential = true
      portMappings = [
        {
          containerPort = 8080
          hostPort      = 8080
        }
      ]
      environment = [
        { name = "NODE_ENV", value = "production" },
        { name = "PORT", value = "8080" }
      ]
      secrets = [
        {
          name      = "DATABASE_URL"
          valueFrom = aws_secretsmanager_secret.db_url.arn
        }
      ]
      logConfiguration = {
        logDriver = "awslogs"
        options = {
          "awslogs-group"         = "/ecs/startup-api"
          "awslogs-region"        = "us-east-1"
          "awslogs-stream-prefix" = "ecs"
        }
      }
    }
  ])
}

resource "aws_ecs_service" "app" {
  name            = "startup-api-service"
  cluster         = aws_ecs_cluster.main.id
  task_definition = aws_ecs_task_definition.app.arn
  desired_count   = 2
  launch_type     = "FARGATE"

  deployment_minimum_healthy_percent = 50
  deployment_maximum_percent         = 200

  network_configuration {
    subnets         = module.vpc.private_subnets
    security_groups = [aws_security_group.ecs_tasks.id]
    assign_public_ip = false
  }

  load_balancer {
    target_group_arn = aws_lb_target_group.app.arn
    container_name   = "api"
    container_port   = 8080
  }
}

4 Provision Amazon Aurora Serverless v2 PostgreSQL (0.5 to 2.0 ACU)

Aurora Serverless v2 scales CPU and memory instantly without dropping active database connections. Setting the minimum capacity to 0.5 Aurora Capacity Units (ACU) keeps idle baseline database costs around ~$43/month while providing instant burst capacity up to 2.0 ACU during customer usage spikes.

terraform/aurora.tf
resource "aws_rds_cluster" "postgresql" {
  cluster_identifier      = "startup-db-cluster"
  engine                  = "aurora-postgresql"
  engine_mode             = "provisioned"
  engine_version          = "16.1"
  database_name           = "appdb"
  master_username         = "appadmin"
  manage_master_user_password = true

  db_subnet_group_name    = module.vpc.database_subnet_group_name
  vpc_security_group_ids  = [aws_security_group.aurora.id]
  storage_encrypted       = true
  deletion_protection     = false
  skip_final_snapshot     = true

  serverlessv2_scaling_configuration {
    min_capacity = 0.5 # 1 GB RAM baseline (~$43/month)
    max_capacity = 2.0 # 4 GB RAM burst ceiling
  }
}

resource "aws_rds_cluster_instance" "primary" {
  cluster_identifier = aws_rds_cluster.postgresql.id
  instance_class     = "db.serverless"
  engine             = aws_rds_cluster.postgresql.engine
  engine_version     = aws_rds_cluster.postgresql.engine_version
}

5 Implement Keyless CI/CD via GitHub Actions OIDC

Never store long-lived AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY tokens in GitHub repository secrets. Use AWS IAM OpenID Connect (OIDC) federation to exchange GitHub Actions cryptographic JWT tokens for temporary, short-lived STS credentials with least-privilege role boundaries.

.github/workflows/deploy.yml
name: Production ECS Deployment
on:
  push:
    branches: [main]

permissions:
  id-token: write # Required for requesting AWS STS JWT
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v4

      - name: Configure AWS Credentials via OIDC
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/github-actions-ecs-deploy
          aws-region: us-east-1

      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v2

      - name: Build, Tag and Push Image to ECR
        env:
          ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
          IMAGE_TAG: ${{ github.sha }}
        run: |
          docker build -t $ECR_REGISTRY/startup-api:$IMAGE_TAG .
          docker push $ECR_REGISTRY/startup-api:$IMAGE_TAG

      - name: Trigger Rolling Deploy on Amazon ECS
        run: |
          aws ecs update-service             --cluster startup-ecs-cluster             --service startup-api-service             --force-new-deployment

Monthly Infrastructure Cost Breakdown (<$100/mo)

Here is the real-world line-item cost breakdown for running this production AWS startup reference architecture in us-east-1:

AWS Resource Configuration / Tier Standard Architecture Startup Optimized
NAT Egress ARM64 t4g.nano fck-nat $65.70 / mo (2 NAT GWs) $3.20 / mo
Compute Tier 2x ECS Fargate Tasks (0.25 vCPU, 0.5 GB) $140.00 / mo (EKS + Nodes) $18.25 / mo
Load Balancer Application Load Balancer (ALB) $16.20 / mo $16.20 / mo
Database Aurora Serverless v2 (0.5 ACU baseline) $43.80 / mo $43.80 / mo
Container Registry Amazon ECR (5 GB stored images) $0.50 / mo $0.50 / mo
DNS & Certificates Route 53 Hosted Zone + ACM Wildcard SSL $0.50 / mo $0.50 / mo
Total Monthly Cost Full Multi-AZ Production SaaS $266.70 / mo $82.45 / mo

Production Troubleshooting Playbook for Startup Stacks

When operating lean AWS infrastructure, follow these diagnostic steps to triage the three most common startup production failures:

1. ALB 504 Gateway Timeout or 502 Bad Gateway

Check the target group health status immediately. Verify that your container application is listening on 0.0.0.0 rather than localhost (127.0.0.1), and ensure the ECS Task security group explicitly permits inbound traffic on port 8080 from the ALB security group.

2. ECS Tasks Stuck in PENDING or Exiting with EssentialContainerExited

Inspect CloudWatch log streams under /ecs/startup-api. Common causes include database connection authentication timeouts (verify Aurora security group allows ECS security group access on port 5432) or missing Secrets Manager IAM read permissions on the execution role.

3. Aurora ACU Capacity Scaling Delay

While Aurora Serverless v2 scales in milliseconds, sudden connection spikes can exhaust thread pools. Always deploy AWS RDS Proxy or configure client-side connection pooling (e.g., PgBouncer or HikariCP) with max connections capped at 50 to avoid memory exhaustion during traffic spikes.