mirror of
https://github.com/karpathy/nanochat.git
synced 2026-05-15 20:27:36 +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>
59 lines
1.6 KiB
HCL
59 lines
1.6 KiB
HCL
terraform {
|
|
required_version = ">= 1.5.0"
|
|
required_providers {
|
|
aws = {
|
|
source = "hashicorp/aws"
|
|
version = ">= 5.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Use an existing hosted zone (created out-of-band when registering the domain).
|
|
data "aws_route53_zone" "this" {
|
|
name = var.domain_name
|
|
private_zone = false
|
|
}
|
|
|
|
# alb_dns_name / alb_zone_id come from the AWS Load Balancer Controller after the
|
|
# Ingress is created (look up via `kubectl get ingress` or a data source). Pass
|
|
# empty strings to skip A-record creation on the first apply, then re-apply.
|
|
resource "aws_route53_record" "apex" {
|
|
count = var.alb_dns_name == "" ? 0 : 1
|
|
|
|
zone_id = data.aws_route53_zone.this.zone_id
|
|
name = var.domain_name
|
|
type = "A"
|
|
|
|
alias {
|
|
name = var.alb_dns_name
|
|
zone_id = var.alb_zone_id
|
|
evaluate_target_health = true
|
|
}
|
|
}
|
|
|
|
resource "aws_route53_record" "subdomains" {
|
|
for_each = var.alb_dns_name == "" ? toset([]) : toset(var.subdomains)
|
|
|
|
zone_id = data.aws_route53_zone.this.zone_id
|
|
name = "${each.key}.${var.domain_name}"
|
|
type = "A"
|
|
|
|
alias {
|
|
name = var.alb_dns_name
|
|
zone_id = var.alb_zone_id
|
|
evaluate_target_health = true
|
|
}
|
|
}
|
|
|
|
# ACM DNS-validation CNAMEs. Pass the map exported by the ACM module.
|
|
resource "aws_route53_record" "acm_validation" {
|
|
for_each = var.acm_validation_records
|
|
|
|
zone_id = data.aws_route53_zone.this.zone_id
|
|
name = each.value.name
|
|
type = each.value.type
|
|
records = [each.value.record]
|
|
ttl = 60
|
|
allow_overwrite = true
|
|
}
|