AWS infrastructure as code
A reservations platform on AWS defined in Terraform. CloudFront and a WAF in front of ECS Fargate and RDS PostgreSQL in private subnets, with tests, security scanning and approval-gated deploys.


- Role
- University team project with five students in 2025; complete redesign and sole author of the current version in 2026
- Period
- Jun 2025 — Jul 2025
- Status
- Completed
- Stack
- Terraform
- AWS
- GitHub Actions
- Docker
- PostgreSQL
- Checkov
- Jenkins
The project started in 2025 as a university team project: a first Terraform deployment of a reservations system, with EC2 instances, a public load balancer, RDS MySQL and Jenkins pipelines. In November 2026 I redesigned it from scratch on my own. The current version defines in Terraform the platform of an event reservations business, with three environments (development, staging and production) that come from a single root module and thirteen modules.
Architecture
- Edge. CloudFront with a WAF is the only public entry point. The static site is served from a private S3 bucket, and
/api/*routes go to an API Gateway HTTP API that validates the JWT issued by Cognito. - Private core. API Gateway reaches an internal load balancer through a VPC Link, and from there ECS Fargate tasks on ARM64 with auto scaling. Nothing inside the VPC is exposed to the internet.
- Data. RDS for PostgreSQL 18 lives in isolated subnets with no outbound route. In production it keeps a standby replica in another zone (Multi-AZ).
- Network. A three-tier VPC across two availability zones. Security groups are chained by reference, from the VPC Link to the load balancer, the tasks and the database; no inbound rule uses an IP range.
Engineering decisions
- The load balancer is internal and still checks a header. API Gateway always exposes its own public address, and calling it directly would skip the WAF. CloudFront adds a secret header and the load balancer answers 403 without it.
- No password in the code or in the state. RDS generates and rotates the database password in Secrets Manager, and ECS injects it when the task starts. CI reaches AWS through GitHub OIDC roles, with no long-lived keys.
- From Aurora to RDS. The first real deployment ran in an AWS Free plan account, which cannot create Aurora Serverless inside a VPC. Rather than move the database out of the private network, I switched to RDS for PostgreSQL and recorded the decision in an ADR.
- Cost by environment. Graviton for the tasks and the database, Fargate Spot and a single NAT outside production, and Multi-AZ in production only. What changes between environments lives in one variables file per environment.
Quality and delivery
- Tests. 25
terraform testcases with a mocked AWS provider: subnet layout, security group chaining, JWT routes, encryption and database high availability. - Scanning. TFLint, Trivy and Checkov, with about 280 policies on the production settings and no failures, against the 62 checks that failed in the original project. Every exception is justified next to its resource, and gitleaks scans the full history for secrets.
- Deploys. Every pull request gets the Terraform plan as a comment. Apply is manual: plan, approval by the environment reviewers, apply of that same saved plan, and smoke tests against the deployed environment.
- Image. The ARM64 application image is pushed to ECR with its software bill of materials (SBOM) and a signed provenance attestation.
- Jenkins. The repository keeps an alternative pipeline with the same checks and a controller configured as code.

The deployed environment
The development environment was deployed to AWS with this same configuration and the version of the latest commit: 115 resources managed by Terraform. It is not kept running, because the NAT, the load balancer and the database are billed by the hour, so what follows is the record of that deployment, from 14 November 2026.
The smoke test of the repository, end to end:
PASS Static site served from S3 via CloudFront 200
PASS API health through CloudFront 200
PASS Anonymous API route 200
PASS Database round-trip over TLS 200
PASS Protected route without a token is rejected 401
PASS WAF blocks a SQL injection probe 403
PASS Calling API Gateway directly (bypassing CloudFront) 403
All checks passed.
The ECS service, with its task running, the deployment completed and the load balancer target healthy:

That Fargate task is what answers on the public route, with the deployed version and its availability zone:

The database, a PostgreSQL instance on Graviton, and the check that makes a round trip to it:


The network: six subnets across two availability zones, each tier with its route table and its ways out.

At the edge, the WAF counted the requests of the tests and blocked the ones carrying a SQL injection; the protected route, without a token, answers 401.


And the CloudWatch dashboard that Terraform itself creates, with one chart per tier: CloudFront, WAF, API Gateway, load balancer, ECS and RDS.

Limits
The API running on Fargate is a placeholder written in TypeScript, with the database schema of the original project ported from MySQL to PostgreSQL. There is no custom domain yet, the application uses the master secret managed by RDS instead of a least-privilege user, and recovery from a regional outage is on the roadmap.