Skip to content

AWS

Deploy the engine in your AWS account with one template: Lambda behind CloudFront at your address, a new RDS Postgres or yours, and SES.

Applies to Engine
View as Markdown
On this page
  1. What it creates
  2. Prepare
  3. Deploy
  4. Keys and a first check
  5. Upgrading and deleting

The template deploy/aws.yaml builds the reference implementation in your account, for one project at your address.

What it creates

  • The engine. The engine on Lambda (arm64) with a function URL. It installs or upgrades the schema when it starts.
  • The events function. A second function for the minute tick (e-mail retries, cleanup), SES bounces and complaints, and admin actions.
  • CloudFront at your address with your certificate. A secret header, kept in Secrets Manager, makes sure nobody skips it to call the function URL directly.
    • Optionally, a Lambda@Edge function that puts back the WWW-Authenticate header, which Lambda function URLs rename; MCP clients need it.
  • Postgres. Either a new RDS PostgreSQL 16 (DatabaseMode=create) or yours (DatabaseMode=existing).
    • A new instance gets a generated password in Secrets Manager. It is publicly reachable with TLS required: the functions run outside a VPC, so narrow DbAllowedCidr when you can.
    • It takes a final snapshot when the stack is deleted.
  • SES. A configuration set wired to bounce handling, and, if you name a domain, its identity with DKIM records.
  • DNS. Route 53 records for your address, when you give the zone.

Prepare

  1. The engine’s Lambda package in an S3 bucket of the same region. Download sypnia-data-lambda-arm64.zip from the release, or build it with cargo lambda build --release --arm64 -p sypnia-data-server --output-format zip.
    Terminal
    aws s3 cp sypnia-data-lambda-arm64.zip s3://my-bucket/sypnia-data/0.1.0/sypnia-data-lambda-arm64.zip
  2. A master key in SSM Parameter Store, generated in place and never pasted anywhere:
    Terminal
    aws ssm put-parameter --name /sypnia-data/master-key --type SecureString --value "$(openssl rand -base64 32)"
  3. A certificate in us-east-1 (ACM) that covers your address, e.g. api.myapp.com.
  4. With your own Postgres, its connection string as an SSM SecureString. It must be a user that can install (create roles and a schema):
    Terminal
    aws ssm put-parameter --name /sypnia-data/database-url --type SecureString --value 'postgres://…?sslmode=require'

Deploy

Terminal
aws cloudformation deploy --stack-name my-data --template-file deploy/aws.yaml --capabilities CAPABILITY_IAM \
  --parameter-overrides CodeBucket=my-bucket CodeKey=sypnia-data/0.1.0/sypnia-data-lambda-arm64.zip \
    DomainName=api.myapp.com CertificateArn=arn:aws:acm:us-east-1:…:certificate/… HostedZoneId=Z0123… \
    DatabaseMode=create MailProvider=ses MailFrom='My app <no-reply@myapp.com>' MailDomain=myapp.com
ParameterDefaultWhat
CodeBucket, CodeKey—, sypnia-data/0.1.0/sypnia-data-lambda-arm64.zipwhere the Lambda package is
MasterKeyParameter/sypnia-data/master-keythe SSM SecureString with the master key
DomainName, CertificateArn—your address and its us-east-1 certificate
HostedZoneIdemptyyour Route 53 zone: alias record and DKIM records
DatabaseModecreatecreate (new RDS) or existing (DatabaseUrlParameter)
DatabaseUrlParameter/sypnia-data/database-urlwith existing: the SSM SecureString with the connection string
DbInstanceClass, DbAllocatedStorage, DbAllowedCidrdb.t4g.micro, 20, 0.0.0.0/0with create
MailProvidersesses, smtp, resend, postmark, none
MailFrom, MailDomainemptythe sender; with SES, the domain to verify
MailSecretParameteremptywith smtp/resend/postmark: an SSM SecureString with the SMTP URL, API key or token
ReservedConcurrency, PoolMax5, 4at most this many instances, each with this many connections
RestoreWwwAuthenticatetruethe Lambda@Edge function; deleting a stack that has it waits for CloudFront to remove its replicas (up to a few hours)

Without HostedZoneId, point your address at the output DistributionDomainName yourself. A new SES account starts in the sandbox: ask AWS for production access before sending to anyone.

Keys and a first check

The first request installs the schema. Then create the project’s keys with the events function (outputs EventsFunction):

Terminal
aws lambda invoke --function-name my-data-events --cli-binary-format raw-in-base64-out \
  --payload '{"action":"api_key","ref":"default","kind":"publishable"}' /dev/stdout
curl https://api.myapp.com/health

Use "kind":"secret" for a secret key, and save its output somewhere safe; it is shown once. The MCP server is at https://api.myapp.com/mcp.

Upgrading and deleting

  • Upgrading. Upload the new package under a new key and deploy again with that CodeKey. The next cold start installs the new migrations, which are additive (upgrades).
  • Deleting. Deleting the stack keeps a final snapshot of a created database. Delete that snapshot yourself when you no longer need it.
  1. What it creates
  2. Prepare
  3. Deploy
  4. Keys and a first check
  5. Upgrading and deleting

    Search pages, sections and terms