# Reference implementation on AWS

> Every AWS service Run uses, what for, and how it is set up.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://run.docs.sypnia.com/architecture/reference-implementation-aws/

For agents: Run on AWS: CloudFront (multi-tenant distribution per cell, custom domains as tenants with ACM certs), CloudFront Functions + KeyValueStore (edge router host→deploy), S3 (one bucket per cell, prefixes, OAC), Lambda (API, deployer, SSR, functions, containers, consumers; version per deploy, alias per environment, function URLs signed by CloudFront), Fargate/ECS behind per-cell ALB with host rules, ECR per app, CodeBuild with per-project build role, EventBridge Scheduler, SQS (FIFO for deploy steps, standard for app queues + DLQ), SSM Parameter Store SecureString, KMS key per project, ACM, CloudWatch Logs, RDS Postgres Multi-AZ; cells = AWS accounts holding a share of projects.

**Figure**: Sypnia Run on AWS: the control plane on the left, the data plane your visitors reach on the right.

The control plane is a Lambda function for the API behind CloudFront, a Postgres database, SQS queues for builds and deploys, CodeBuild for builds, and a Lambda deployer. The data plane is one CloudFront distribution with an edge function and a key-value store, an S3 bucket of artifacts, Lambda functions and Fargate services per app, EventBridge Scheduler for jobs and SQS for app queues. Secrets live in Parameter Store, encrypted with KMS keys per project.

| Service                              | Used for                                                                              | Setup                                                                                                                    |
| ------------------------------------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| Amazon CloudFront                    | every app's address, TLS, caching                                                     | multi-tenant distribution per cell; custom domains as distribution tenants with their own ACM certificates               |
| CloudFront Functions + KeyValueStore | the edge router: host → deploy                                                        | one KVS per cell; updates are the release step                                                                           |
| Amazon S3                            | build sources, artifacts, static files, build cache                                   | one bucket per cell, prefix per project/app/deploy; only CloudFront (origin access control) reads static files           |
| AWS Lambda                           | the Run API, the deployer, SSR servers, functions, Lambda containers, queue consumers | one function per app server or function, a version per deploy, alias per environment; function URLs signed by CloudFront |
| AWS Fargate (ECS)                    | always-on containers                                                                  | one service per app and environment, behind an Application Load Balancer per cell with host-based rules                  |
| Amazon ECR                           | container images                                                                      | a repository per app, images by digest per deploy                                                                        |
| AWS CodeBuild                        | builds                                                                                | one project per build image; each build assumes the project's build role                                                 |
| Amazon EventBridge Scheduler         | scheduled jobs                                                                        | one schedule per job and environment, targeting the job's function or an ECS task                                        |
| Amazon SQS                           | the control plane's work queues; app queues and their dead-letter queues              | FIFO for deploy steps per app, standard for app queues                                                                   |
| AWS Systems Manager Parameter Store  | variables and secrets                                                                 | `SecureString` per variable, path per project/app/environment                                                            |
| AWS KMS                              | encrypting secrets and artifacts                                                      | one key per project                                                                                                      |
| AWS Certificate Manager              | certificates for custom domains                                                       | DNS validation, automatic renewal                                                                                        |
| Amazon CloudWatch Logs               | app and build logs                                                                    | log group per app and environment, retention per plan                                                                    |
| Amazon RDS for PostgreSQL            | the control plane's state                                                             | Multi-AZ in Sypnia Cloud                                                                                                 |

## Cells

Sypnia Cloud runs projects in **cells**: AWS accounts that each hold a share of the projects, with their own CloudFront distribution, bucket, load balancer and quotas. A cell's failure or quota limit affects only its projects, and a busy project can be moved to a cell of its own. [Isolation](https://run.docs.sypnia.com/architecture/isolation) explains the boundaries inside a cell.
