# Install on AWS

> The engine's CloudFormation stack, its parameters, the permissions it needs and how to remove it.

Applies to: the Sypnia engine (open source, self-hosted).  
Source: https://run.docs.sypnia.com/self-hosting/aws/

For agents: Run engine on AWS: npx @sypnia/run engine install --region [--domain --certificate-arn] deploys published template deploy/engine.yaml; creates Lambda run-api and run-deployer, RDS Postgres db.t4g.micro (or --database-url), S3 bucket, CodeBuild projects, SQS + DLQs, CloudFront with edge router, ALB on first Fargate app, KMS key + SSM paths, IAM roles (least privilege, resources tagged sypnia-run); parameters Domain, CertificateArn, AppsDomain (wildcard for apps), DatabaseUrl, ContainerSupport, AlarmEmail; uninstall deletes app stacks then engine, keeps bucket and DB unless --delete-data.

```bash
npx @sypnia/run engine install --region us-east-1 [--domain run.example.com --certificate-arn arn:aws:acm:…]
```

The command packages nothing on your machine: it deploys the published template `deploy/engine.yaml` of the engine's version with the parameters you give.

## What the stack creates

| Resource                                                                            | Purpose                                  |
| ----------------------------------------------------------------------------------- | ---------------------------------------- |
| Lambda functions `run-api`, `run-deployer`                                          | the engine                               |
| An RDS PostgreSQL instance (`db.t4g.micro`), or your database with `--database-url` | the engine's state                       |
| An S3 bucket `sypnia-run-<account>-<region>`                                        | sources, artifacts, static files, caches |
| CodeBuild projects                                                                  | builds in your account                   |
| SQS queues and their dead-letter queues                                             | the engine's work                        |
| A CloudFront distribution with the edge router                                      | every app's address                      |
| An Application Load Balancer, created on the first Fargate app                      | containers                               |
| A KMS key and Parameter Store paths                                                 | secrets                                  |
| IAM roles: API, deployer, build, and per-app execution roles created on demand      | least privilege                          |

## Parameters

| Parameter          | Default     | Meaning                                                                                      |
| ------------------ | ----------- | -------------------------------------------------------------------------------------------- |
| `Domain`           | none        | The engine's own address (`run.example.com`); without it, the CloudFront address             |
| `CertificateArn`   | none        | Certificate for `Domain`, in us-east-1                                                       |
| `AppsDomain`       | none        | A wildcard domain for apps (`*.apps.example.com`), so each app gets `<app>.apps.example.com` |
| `DatabaseUrl`      | creates RDS | Use an existing Postgres 14+                                                                 |
| `ContainerSupport` | `true`      | Creates the VPC pieces for Fargate on first use                                              |
| `AlarmEmail`       | none        | Where dead-letter and error alarms are sent                                                  |

## Permissions

Installing needs permission to create the resources above. Day to day, the engine's roles can only manage resources tagged `sypnia-run`, in the stack's region.

## Removing it

`npx @sypnia/run engine uninstall` deletes every app stack first (asking for confirmation), then the engine's stack. The S3 bucket and the database are kept unless you add `--delete-data`.
