Skip to content
sdedu.cloud
← projects

Fissure

The infrastructure of my mobile app, moved from a public EC2 instance with a Security Group open on every port to ECS Fargate and Multi-AZ RDS in private subnets, all in Terraform.

  • Public EC2 → ECS Fargate behind an ALB
  • Multi-AZ RDS PostgreSQL across 2 AZs, in private subnets
  • Compute from ~$30/month fixed to ~$8-15/month
stack
AWSECS FargateRDS Multi-AZALBECRVPCTerraform
links
app landing page ↗full write-up →

Context

Fissure is a mobile app to track calories and workouts in one place, with Gemini to make the data easier to log (React Native and Expo for the app, ExpressJS with a clean architecture for the back end, PostgreSQL for the data). It is while trying to deploy it that I got hooked on the Cloud, and the interesting part here is not the app itself: it is the path from a catastrophic first deployment to the current infrastructure.

The constraints were those of a personal project: a tight budget, the wish to keep control of the infrastructure rather than going fully serverless, and very little networking knowledge at the start. Scroll down, the architecture rebuilds itself step by step.

Fissure AWS architecture, from a public EC2 instance to ECS Fargate and Multi-AZ RDSaws · regioninternet*:* openyoussh + git cloneec2 · t3.mediumapi expresspostgres on ebssg 0.0.0.0/0 · all portspublic subnet · all exposedvpcaz-aaz-bpublicprivate · appprivate · datapublicprivate · appprivate · dataapplication load balancernatapifargateapifargateapifargateapifargategit push ↓ecrimagesrds primarypostgresqlrds standbypostgresqlsyncautomated backupsterraformmodules/networkecsrdsenvs/dev ✓staging ✓prod ✓

v0

The catastrophic deployment

A public EC2 instance, a Security Group open on every port to 0.0.0.0/0, a manual deployment over SSH and git clone, and the database on the instance’s EBS volume. Everything in the public subnet.

v1

Isolating the network

A VPC split into public and private subnets across two Availability Zones. Whatever computes or stores data will never be reachable directly again.

v2

A single entry point

An Application Load Balancer in the public subnets: traffic distribution, health checks, SSL termination. A NAT Gateway so the private side can reach out without being exposed.

v3

Compute without servers to manage

ECS Fargate in the private subnets. Images are pushed to ECR, the deployment follows, and the service scales on CPU and memory load.

v4

Data that survives

Multi-AZ RDS PostgreSQL: a primary instance, a synchronous standby in the other AZ, automatic backups and failover without intervention.

v5

Everything as code

The whole setup is described in Terraform, in modules, with separate environments. Result: about 60% lower costs than the original EC2 instance.

What I took from it

Security has to be designed in from the start (private subnets, IAM roles, encryption), because it is much harder to add afterwards. Deploying by hand over SSH was a nightmare: Terraform and automatic deployments through ECR transformed my workflow and make rollbacks possible in minutes. And an always-on instance costs a lot even without traffic, which taught me to track costs from day one with Cost Explorer.

What’s left

The next version will add an S3 bucket with image resizing through Lambda, and a cache layer with ElastiCache Redis.

The code is private: the full write-up, with the mistakes of the first deployment and the cost breakdown, is on the blog.