Cloud
5 min read
November 22, 2026
AWS architecture for SaaS: a reference setup
A reference AWS architecture for SaaS: accounts and networking, ECS Fargate or Lambda, Aurora PostgreSQL, ElastiCache, S3, SQS and EventBridge, security, observability, infrastructure as code and cost control.
By Parth Patel
AWS offers hundreds of services, and it is easy to build a SaaS platform that uses too many of them. A good AWS architecture for SaaS uses a small set of managed services well: it is secure by default, cheap at low traffic, and able to grow without a redesign.
This is a reference setup for an early to mid-stage SaaS product, with the reasoning behind each choice and the points where you would change it.
Accounts and environments
Start with separate AWS accounts for production, staging and development, managed through AWS Organizations, plus a shared account for logging and security. Account boundaries are the strongest isolation AWS offers: a mistake in staging cannot touch production data, and billing is clear per environment.
Use IAM Identity Center for human access with short-lived credentials and MFA. No long-lived access keys for people.
Networking
Each environment gets a VPC across at least two Availability Zones:
- Public subnets for the load balancer only.
- Private subnets for application containers.
- Isolated subnets for databases, with no route to the internet.
Use VPC endpoints for AWS services (S3, ECR, Secrets Manager) so traffic stays private, and NAT gateways only where outbound internet access is needed. NAT data charges are a common surprise; endpoints reduce them.
The application tier
For most SaaS teams, containers on ECS with Fargate are the sweet spot: no servers to patch, per-service scaling, and far less operational work than Kubernetes. Choose EKS when you already have Kubernetes expertise or need its ecosystem. Lambda suits event-driven pieces such as webhooks, file processing and scheduled jobs, and can run whole APIs at low steady traffic.
In front of the services:
- CloudFront as the CDN for the web app and static assets, with AWS WAF for common attack patterns and rate limiting.
- An Application Load Balancer routing to API services, with health checks and HTTPS via ACM certificates.
Run at least two tasks per service across Availability Zones, and autoscale on CPU, memory or request count.
Data
- Amazon RDS or Aurora PostgreSQL as the system of record, Multi-AZ in production, with automated backups and point-in-time recovery. Tenant isolation with row-level security, as described in the multi-tenant architecture guide.
- Read replicas when read load grows.
- ElastiCache for Redis (or Valkey) for caching, rate limiting and sessions.
- S3 for files, with tenant-prefixed keys, encryption by default, blocked public access, and pre-signed URLs for upload and download.
Put RDS Proxy in front of the database if Lambda functions or many containers connect to it, so connection counts stay under control.
Background work and events
- SQS for job queues: sending email, generating reports, calling webhooks. Use dead-letter queues and alarms on their depth.
- EventBridge for domain events between services and for schedules.
- SNS for fan-out notifications where needed.
- Consider Amazon MSK (managed Kafka) only when you need event streaming and replay at volume; see Kafka vs RabbitMQ.
Identity for your users
Amazon Cognito can handle sign-up, sign-in, MFA and federation with enterprise identity providers. Many teams prefer a dedicated identity provider or library for richer B2B features (organizations, SSO per tenant, SCIM). Either way, keep authorization (who may do what in which tenant) in your application.
Secrets and security
- Secrets Manager or Parameter Store for database credentials and API keys, injected into tasks at runtime. Never in code, images or environment files in the repository.
- KMS encryption for databases, S3 and backups.
- Least-privilege IAM roles per service.
- GuardDuty, Security Hub and CloudTrail (in the logging account) for threat detection and audit.
These are also the answers enterprise customers' security questionnaires ask for.
Observability
- CloudWatch logs and metrics for every service, with structured JSON logs that include tenant and request IDs.
- AWS X-Ray or OpenTelemetry for distributed tracing.
- Alarms on what users feel: 5xx rate, p95 latency, queue age and database CPU or connections.
- Per-tenant dashboards where large customers can affect shared resources.
Infrastructure as code and delivery
Define everything with Terraform or AWS CDK, reviewed in pull requests, so environments can be rebuilt and audited. A CI/CD pipeline (GitHub Actions or CodePipeline) builds container images, pushes them to ECR, runs migrations safely and deploys with rolling or blue-green releases.
Keeping costs under control
- Tag every resource by environment, service and, where possible, tenant.
- Use Savings Plans once usage is steady; Fargate Spot for interruptible workloads.
- Watch NAT gateway, data transfer and CloudWatch log volumes, the usual hidden costs.
- Right-size databases from real metrics and set budgets with alerts.
How it fits together
A request flows through CloudFront and WAF to the load balancer, to an API service on ECS Fargate in private subnets, which reads and writes Aurora PostgreSQL (with Redis for caching), stores files in S3, and hands slow work to SQS-driven workers. Logs, metrics and traces flow to CloudWatch; everything is defined in Terraform and deployed by the pipeline.
This setup runs a typical SaaS product from its first customer to well beyond, and it changes in predictable places as you grow: replicas for reads, dedicated resources for large tenants, and more services only where the architecture calls for them.