AWS Builder Center

I Gave Myself 21 Days to Build a Production SaaS on AWS. Here Is What Happened.

A complete walkthrough of building StatusNest, a production multi-tenant uptime monitoring platform on AWS using ECS Fargate, RDS PostgreSQL, Lambda, EventBridge, SQS, CloudFront, WAF, and Terraform IaC across four repositories. Covers every architecture decision and why, plus the real failures, ECS tasks stuck at zero, OIDC silent rejections, Terraform state drift, WAF blocking your own requests - and exactly how each one was resolved.

Associate Solutions Architect | AWS · Kubernetes · Terraform · CI/CD | Technical Author



The idea

StatusNest started as a question I kept asking myself: what does it actually take to build a SaaS product from scratch on AWS, the right way, with no shortcuts?
Not a tutorial project. Not a proof of concept. A real multi-tenant monitoring platform where different organizations each get their own isolated data, their own dashboard, their own monitors, all running on shared infrastructure that I provisioned with zero manual console clicks.
This article is the story of how I built it, every architecture decision I made and why, and the failures that cost me the most time. If you want to build something like this yourself, read the failure sections carefully. That is where the real education is.



What StatusNest actually does

StatusNest is an uptime monitoring platform. Organizations sign up, create monitors for their websites and APIs, and get a status dashboard showing whether everything is up or down. Multiple organizations share the same infrastructure but their data is completely isolated from each other, that is the multi-tenant part.
The architecture has three microservices: an auth service handling registration and login, a monitor service managing monitor configuration, and a status service tracking uptime results. Two Lambda workers run separately, one that checks monitors on a schedule, one that processes the results. An SQS queue sits between them so the checking and processing are decoupled.

Every resource, VPC, subnets, ECS cluster, ALB, ECR repositories, Lambda functions, SQS queue, RDS instance, CloudFront distribution, WAF rules, CloudWatch dashboards, was created and managed through modular Terraform. Four repositories: infrastructure, API, workers, frontend.



The architecture decisions

Why ECS Fargate and not Lambda for the API

The three microservices run as long-lived containers on ECS Fargate rather than Lambda functions. Lambda is the right answer for event-driven, short-lived work, which is exactly why the monitor worker and processor worker are Lambda. But an API that handles authentication and serves dashboard data benefits from a persistent container. No cold starts on login requests, no 15-minute execution limit, and the Flask application model maps naturally to a running process rather than a function invocation.
Fargate specifically means no EC2 instances to patch, no cluster nodes to manage. You define the task, specify the CPU and memory, and AWS runs the container. For a solo-built project this matters, fewer things to operate means more time writing actual code.

Why RDS PostgreSQL and not DynamoDB

Multi-tenancy with relational data is where PostgreSQL earns its place. Every monitor, every status check, every user account has relationships to other records. Tenant isolation is enforced at the row level using an  organization_id  column on every table, every query filters by it. In a relational database this is straightforward. In DynamoDB you would be fighting the data model constantly.
The tradeoff is cost and operational overhead. RDS runs 24 hours a day regardless of traffic, which DynamoDB on-demand does not. For a production system with real revenue, RDS is correct. For a personal project, it is the more expensive choice, and I made it deliberately because the data model justified it.

Why CloudFront in front of everything

CloudFront sits in front of the ALB and the S3-hosted frontend. For the frontend, this is obvious,, static assets served from edge locations load faster than a single-region S3 bucket. For the API, CloudFront adds a layer where WAF rules run before traffic ever reaches the application. A request that matches a WAF rule gets blocked at the edge. It never touches the ALB, never touches ECS, never generates a log entry in the application.
The WAF setup caused problems during testing, which I will get to shortly.

Why GitHub Actions with OIDC and not stored credentials

Every CI/CD pipeline that stores AWS access keys in GitHub Secrets is one leaked secret away from a compromised AWS account. OIDC eliminates stored credentials entirely. GitHub Actions requests a short-lived token from AWS STS at runtime, assumes an IAM role with exactly the permissions needed for that pipeline, and the token expires when the job finishes. Nothing to rotate, nothing to leak, nothing sitting in a secrets store waiting to be found.
Setting this up correctly took several attempts. More on that below.



What broke and how to get past it

ECS services stuck at zero running tasks

This was the worst one. The monitor-service and status-service would not start. ECS kept launching tasks that immediately died with exit code 1. No useful logs because the containers were not alive long enough to write any.
The root cause was a port mismatch in the task definitions. These two services had been created outside of Terraform during early testing, which meant their task definitions had the wrong container port mappings. The Flask application was listening on port 5000. The task definition said port 80. ECS launched the container, the health check on port 80 found nothing, and the task was killed.
The fix required manually registering corrected task definitions through the CLI and updating the ECS services to use them. Then importing those resources into Terraform state so the infrastructure was managed consistently going forward.
The lesson: if you create anything manually during testing, either delete it before Terraform takes over or import it into state immediately. A resource that exists in AWS but not in Terraform state is a ticking conflict waiting to surface at the worst possible moment.

GitHub Actions OIDC failing silently

The CI/CD pipeline could not authenticate with AWS. The error was an authorization failure on  AssumeRoleWithWebIdentity  with no further detail.
OIDC trust policies use a  sub  claim to verify the identity of the calling workflow. The format encodes the repository name, branch, and environment. One wrong character anywhere in that string and AWS rejects the token without explaining why. In my case the trust policy condition had the wrong branch reference.
When you configure this, do not guess at the sub claim format. Go to the AWS documentation, copy the exact format, and verify it matches your repository and branch before you run a single workflow. The debugging experience for a wrong sub claim is, I say this from experience, genuinely unpleasant.

Terraform state drift

Because some ECS resources were created outside Terraform during debugging, the state drifted. Terraform would try to recreate resources that already existed, or would conflict with manually created ones, and the apply would fail halfway through.
The fix was using  terraform import  to bring the manually created resources into state, then continuing. But the broader discipline is this: once you decide a project is Terraform-managed, everything goes through Terraform. No exceptions, no "I will just quickly create this one thing in the console." That shortcut will cost you more time than it saves, reliably, every time.

WAF blocking legitimate requests

During testing, WAF rules were blocking requests that were clearly legitimate. API calls from the frontend were returning 403 responses from CloudFront with no explanation.
WAF managed rule groups are opaque by design, they match patterns across the request and block anything that looks suspicious. During development your test requests often look suspicious because they come from a single IP, repeat quickly, and sometimes contain patterns that overlap with known attack signatures.
The fix is to run WAF in count mode during development rather than block mode. Count mode logs every rule match without actually blocking anything. You see exactly which rules are firing on your requests, adjust accordingly, and switch to block mode when the application is behaving normally under real traffic.

The EventBridge to Lambda to SQS permission chain

Getting the event pipeline working required correct IAM permissions at every hop. EventBridge needs permission to invoke the Lambda function. Lambda needs permission to write to SQS. The processor Lambda needs permission to read from SQS and write to RDS.
Miss any one of those and the pipeline breaks silently. No error surfaces to the caller, the event just disappears somewhere in the chain. The debugging process is working backward from the end: check whether records are appearing in RDS, then check SQS for unprocessed messages, then check Lambda logs, then check EventBridge for failed invocations.
Build the permission chain one hop at a time and verify each hop works before adding the next. Testing the full pipeline end-to-end before each individual piece is confirmed working is how you end up spending three hours staring at an empty database.



The observability setup

CloudWatch dashboards track ECS CPU and memory across all three services, ALB request count and response time, SQS queue depth, and Lambda invocation count and error rate. Alarms fire when CPU goes above 80% on any service or when the SQS queue depth exceeds a threshold that suggests the processor is falling behind.
X-Ray distributed tracing is configured with a custom sampling rule scoped to the StatusNest service group. When a request comes in through the ALB, X-Ray traces it through the ECS service and into any downstream calls. The service map shows exactly where time is being spent, which is how you find a slow database query without adding timing logs everywhere.
Set up observability before you think you need it. I added X-Ray after the ECS debugging sessions and immediately wished I had had it earlier. A service map showing a task dying 200ms after launch would have pointed directly at the port mismatch instead of the hour of log archaeology that actually happened.



The CI/CD pipeline

Each of the four repositories has its own GitHub Actions workflow. A push to the API repository triggers a build that logs into ECR via OIDC, builds and tags the Docker image with the commit SHA, pushes it to ECR, and forces a rolling redeploy of the affected ECS service. The infrastructure repository triggers a Terraform plan on pull request and apply on merge to main.
Using the commit SHA as the Docker image tag rather than  latest  means every deployment is traceable. If something breaks after a deploy, you know exactly which commit introduced it and you can roll back by forcing ECS to use the previous image tag.



What to take from this

StatusNest is on GitHub at github.com/aboodi679. The full Terraform modules, the four service repositories, and the architecture documentation are all there.
The thing I would tell anyone starting a project like this: the architecture decisions are the easy part. Reading about ECS Fargate versus EC2, RDS versus DynamoDB, CloudFront versus direct ALB exposure, that takes an afternoon. The hard part is the ECS service that will not start, the IAM role that rejects a perfectly formatted OIDC token, the WAF rule that blocks your own test requests. That is where the actual learning happens.
Build it. Break it. Read the error. Fix it. That sequence, repeated enough times, is the only way to actually understand what you are building.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article