Skip to content
All work
Case study 08Staging live

OpenHR infrastructure

The Terraform for OpenHR on AWS: Fargate services, regional Postgres for data residency, and a staging environment that puts itself to sleep.

RoleCloud engineer
Year2026
AreaCloud · AWS
Stack
AWSTerraformECS FargateRDSLambdaCloudFront

The brief

OpenHR is a hiring platform whose users’ data has to stay in their own region. I wrote the Terraform that runs it on AWS, in its own repository, and wrote down every decision and why in a DECISIONS.md file.

What I built

Compute. Everything runs on ECS Fargate: the API, an email worker, the ClamAV scanner and the admin tools. I started with App Runner and dropped it, because it cannot host a background worker or the scanner.

Data residency. Each real region gets its own RDS Postgres instance, and a global database sits with the API in the home region. Production launches in the UK and EU (eu-west-2 and eu-central-1), joined by VPC peering. The other three regions are placeholders served from the home region, with a documented risk so nobody offers those markets by accident.

The edge. CloudFront and AWS WAF sit in front of the load balancer, with managed rules and rate limits. The load balancer only accepts traffic that arrives through CloudFront.

Jobs and releases. Scheduled work runs as ECS tasks started by EventBridge Scheduler. Database migrations run as a one-off ECS task triggered from GitHub Actions over OIDC, so the database stays private and no long-lived keys exist.

Secrets. Terraform creates the secrets empty and the values are set separately, so they never enter state.

A staging environment that sleeps

Staging runs on Fargate Spot, a small RDS instance and Redis on a Spot task backed by EFS. A Lambda function scales everything to zero after an hour with no logged-in traffic and stops the database. Visitors see a “wake staging” page. This took staging from about $90 a month to about $55 while idle.

Where it stands

Staging is deployed. Production passes terraform validate but has not been planned or applied yet.

How it fits together

The system, in 3D

Services: CloudFront + WAF, ALB, ECS Fargate, RDS per region, S3 uploads, ClamAV. Connections: CloudFront + WAF to ALB; ALB to ECS Fargate; ECS Fargate to RDS per region; ECS Fargate to S3 uploads; ECS Fargate to ClamAV.
CloudFront + WAF
ALB
ECS Fargate
RDS per region
S3 uploads
ClamAV
Next project
09BloomingBet infrastructureCloud engineer2026