mirror of
https://github.com/karpathy/nanochat.git
synced 2026-05-10 09:50:25 +00:00
Add reusable Terraform modules and per-environment configs (dev/uat/prod) in us-west-2 covering: VPC (3 AZ public/private), EKS 1.29 with IRSA and ALB/EBS/EFS CSI add-ons, RDS PostgreSQL 15, four ECR repos, IAM roles (EKS node, ALB controller IRSA, GitHub Actions OIDC), Route53 + ACM for samosachaat.art, and EFS for model weights. State backend on S3 (samosachaat-terraform-state) with DynamoDB lock table. terraform validate passes for dev, uat, and prod. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
74 lines
1.5 KiB
HCL
74 lines
1.5 KiB
HCL
terraform {
|
|
required_version = ">= 1.5.0"
|
|
required_providers {
|
|
aws = {
|
|
source = "hashicorp/aws"
|
|
version = ">= 5.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
resource "aws_security_group" "efs" {
|
|
name = "${var.name}-efs-sg"
|
|
description = "NFS from EKS nodes to model-weights EFS"
|
|
vpc_id = var.vpc_id
|
|
|
|
ingress {
|
|
description = "NFS from EKS nodes"
|
|
from_port = 2049
|
|
to_port = 2049
|
|
protocol = "tcp"
|
|
security_groups = [var.eks_node_security_group_id]
|
|
}
|
|
|
|
egress {
|
|
from_port = 0
|
|
to_port = 0
|
|
protocol = "-1"
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
|
|
tags = var.tags
|
|
}
|
|
|
|
resource "aws_efs_file_system" "this" {
|
|
creation_token = var.name
|
|
encrypted = true
|
|
performance_mode = var.performance_mode
|
|
throughput_mode = var.throughput_mode
|
|
|
|
lifecycle_policy {
|
|
transition_to_ia = "AFTER_30_DAYS"
|
|
}
|
|
|
|
tags = merge(var.tags, { Name = var.name })
|
|
}
|
|
|
|
resource "aws_efs_mount_target" "this" {
|
|
for_each = toset(var.private_subnet_ids)
|
|
file_system_id = aws_efs_file_system.this.id
|
|
subnet_id = each.key
|
|
security_groups = [aws_security_group.efs.id]
|
|
}
|
|
|
|
# Access point used by inference pods (UID/GID match the container user).
|
|
resource "aws_efs_access_point" "model_weights" {
|
|
file_system_id = aws_efs_file_system.this.id
|
|
|
|
posix_user {
|
|
uid = 1000
|
|
gid = 1000
|
|
}
|
|
|
|
root_directory {
|
|
path = "/model-weights"
|
|
creation_info {
|
|
owner_uid = 1000
|
|
owner_gid = 1000
|
|
permissions = "0755"
|
|
}
|
|
}
|
|
|
|
tags = var.tags
|
|
}
|