Phase 2 sections 2-6 and 8 of docs/SCALE-EXPANSION.md: - pkg/telemetry + pkg/metrics: OpenTelemetry trace propagation and Prometheus metrics across every service hop (CLI -> agent -> gateway -> card-issuance/tenant-registry/auth -> ledger-core), tracing added to ledger-core itself via services/ledger-core/src/telemetry.rs. - infra/: otel-collector + Prometheus + Grafana docker-compose stack, a Terraform ECS Fargate module + dev/staging/prod envs (plan-only, no apply — real AWS spend is an owner action), and a dev-only mTLS CA (infra/dev-ca) wired through pkg/mtls + services/ledger-core/src/mtls.rs. - services/audit-log (from the prior commit) gets its async mirror writer in services/ledger-core/src/audit_mirror.rs, and services/gateway gets a per-tenant token-bucket rate limiter (internal/ratelimit). - Test depth: a Rust proptest suite proving concurrent ApplyEntry never breaches the reserve floor (tests/apply_entry_proptest.rs, passing), a Go fuzz seed corpus for the policy envelope (rules_fuzz_test.go), a libFuzzer harness for the C WAL frame parser (services/wal/fuzz, deliberately not wired into `make test` per its own Makefile comment - needs a libFuzzer-bundled clang), and a real chaos test (scripts/chaos/kill-ledger-mid-write.sh) that SIGKILLs ledger-core mid-write under concurrent load and verifies via ListEntries that nothing was lost or double-applied. - docs/formal/ledger.tla: a TLA+ spec of the ledger state machine (balance >= reserve_floor safety, HOLD-eventually-resolves liveness) plus a TLC model config - not run through TLC in this pass, that's a precise documented TODO, not faked. - docs/adr/0001-0004, docs/RUNBOOK.md, docs/SLO.md, docs/THREAT-MODEL.md. Verified: `make build && make test` clean (C WAL, Rust incl. the new proptest suite, all 10 Go modules) from a cold target. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
113 lines
3.3 KiB
HCL
113 lines
3.3 KiB
HCL
# Shared VPC module — docs/SCALE-EXPANSION.md section 3: "a shared VPC
|
|
# module". Deliberately minimal (one VPC, public+private subnets per AZ,
|
|
# IGW, NAT) rather than pulling in terraform-aws-modules/vpc: this repo has
|
|
# no real traffic shaping/peering requirements yet, and a hand-rolled
|
|
# module keeps `terraform plan`'s output small enough to actually read.
|
|
|
|
terraform {
|
|
required_version = ">= 1.5.0"
|
|
|
|
required_providers {
|
|
aws = {
|
|
source = "hashicorp/aws"
|
|
version = ">= 5.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
locals {
|
|
tags = merge(var.tags, {
|
|
ManagedBy = "terraform"
|
|
})
|
|
}
|
|
|
|
resource "aws_vpc" "this" {
|
|
cidr_block = var.cidr_block
|
|
enable_dns_support = true
|
|
enable_dns_hostnames = true
|
|
|
|
tags = merge(local.tags, { Name = var.name })
|
|
}
|
|
|
|
resource "aws_internet_gateway" "this" {
|
|
vpc_id = aws_vpc.this.id
|
|
tags = merge(local.tags, { Name = "${var.name}-igw" })
|
|
}
|
|
|
|
# /20 per subnet out of the /16 — plenty of room (4094 hosts) per AZ for
|
|
# ECS task ENIs (awsvpc mode means every task consumes an IP).
|
|
resource "aws_subnet" "public" {
|
|
for_each = { for idx, az in var.azs : az => idx }
|
|
|
|
vpc_id = aws_vpc.this.id
|
|
availability_zone = each.key
|
|
cidr_block = cidrsubnet(var.cidr_block, 4, each.value)
|
|
map_public_ip_on_launch = true
|
|
|
|
tags = merge(local.tags, { Name = "${var.name}-public-${each.key}", Tier = "public" })
|
|
}
|
|
|
|
resource "aws_subnet" "private" {
|
|
for_each = { for idx, az in var.azs : az => idx }
|
|
|
|
vpc_id = aws_vpc.this.id
|
|
availability_zone = each.key
|
|
cidr_block = cidrsubnet(var.cidr_block, 4, each.value + length(var.azs))
|
|
|
|
tags = merge(local.tags, { Name = "${var.name}-private-${each.key}", Tier = "private" })
|
|
}
|
|
|
|
resource "aws_eip" "nat" {
|
|
for_each = var.single_nat_gateway ? toset([var.azs[0]]) : toset(var.azs)
|
|
domain = "vpc"
|
|
|
|
tags = merge(local.tags, { Name = "${var.name}-nat-${each.key}" })
|
|
}
|
|
|
|
resource "aws_nat_gateway" "this" {
|
|
for_each = var.single_nat_gateway ? toset([var.azs[0]]) : toset(var.azs)
|
|
|
|
allocation_id = aws_eip.nat[each.key].id
|
|
subnet_id = aws_subnet.public[each.key].id
|
|
|
|
tags = merge(local.tags, { Name = "${var.name}-nat-${each.key}" })
|
|
|
|
depends_on = [aws_internet_gateway.this]
|
|
}
|
|
|
|
resource "aws_route_table" "public" {
|
|
vpc_id = aws_vpc.this.id
|
|
tags = merge(local.tags, { Name = "${var.name}-public" })
|
|
|
|
route {
|
|
cidr_block = "0.0.0.0/0"
|
|
gateway_id = aws_internet_gateway.this.id
|
|
}
|
|
}
|
|
|
|
resource "aws_route_table_association" "public" {
|
|
for_each = aws_subnet.public
|
|
subnet_id = each.value.id
|
|
route_table_id = aws_route_table.public.id
|
|
}
|
|
|
|
# One private route table per AZ when NAT is per-AZ (so an AZ's egress
|
|
# never crosses to another AZ's NAT); one shared table when single_nat_gateway.
|
|
resource "aws_route_table" "private" {
|
|
for_each = var.single_nat_gateway ? toset(["shared"]) : toset(var.azs)
|
|
|
|
vpc_id = aws_vpc.this.id
|
|
tags = merge(local.tags, { Name = "${var.name}-private-${each.key}" })
|
|
|
|
route {
|
|
cidr_block = "0.0.0.0/0"
|
|
nat_gateway_id = var.single_nat_gateway ? aws_nat_gateway.this[var.azs[0]].id : aws_nat_gateway.this[each.key].id
|
|
}
|
|
}
|
|
|
|
resource "aws_route_table_association" "private" {
|
|
for_each = aws_subnet.private
|
|
subnet_id = each.value.id
|
|
route_table_id = var.single_nat_gateway ? aws_route_table.private["shared"].id : aws_route_table.private[each.key].id
|
|
}
|