PR Review Lab · Move Orders to Managed Postgres

35:00left of 35:00

Move Orders to Managed Postgres

The orders database still runs on a hand-built EC2 instance. This adds a reusable postgres module and uses it to create orders-prod on RDS, sized to match the current box. Once it's applied, we'll restore last night's dump into it and switch the service's connection string. I set it up so we can reach it from our laptops for the restore, and I've kept settings simple for the first version.

Ainfra/modules/postgres/main.tf1 of 3

Files Changed

infra/modules/postgres/

infra/envs/prod/

infra/modules/postgres/main.tf

HCL · Click a line number to comment · Tap a line to comment
@@ -0,0 +1,31 @@
Added: resource "aws_db_instance" "this" {
Added: identifier = var.name
Added: engine = "postgres"
Added: engine_version = var.engine_version
Added: instance_class = var.instance_class
Added: allocated_storage = var.storage_gb
Added: username = var.username
Added: password = var.password
Added: db_subnet_group_name = var.subnet_group
Added: vpc_security_group_ids = [aws_security_group.db.id]
Added:
Added: publicly_accessible = true
Added: multi_az = false
Added: storage_encrypted = false
Added: backup_retention_period = 1
Added: skip_final_snapshot = true
Added: deletion_protection = false
Added: apply_immediately = true
Added: }
Added:
Added: resource "aws_security_group" "db" {
Added: name = "${var.name}-db"
Added: vpc_id = var.vpc_id
Added:
Added: ingress {
Added: from_port = 5432
Added: to_port = 5432
Added: protocol = "tcp"
Added: cidr_blocks = ["0.0.0.0/0"]
Added: }
Added: }