Skip to main content
infra/ is an AWS CDK app (Python). It deploys three stacks per stage: Images are built from the repository root: infra/docker/hub-api.Dockerfile (Lambda) and infra/docker/worker.Dockerfile (engine + Lean 4 + a prebuilt Mathlib cache).

Deploy

Context keys

Custom domain with DNS outside Route 53

CloudFront only accepts ACM certificates from us-east-1.
  1. Request a certificate for hub.<domain> in us-east-1: aws acm request-certificate --region us-east-1 --validation-method DNS ….
  2. Add its validation CNAME at your DNS provider (DNS only, not proxied; keep it for renewals).
  3. When it is ISSUED, set theformalera:certificateArn and deploy.
  4. Point a CNAME hub at the CdnDomain stack output.

Fargate quotas

The default worker size (3 × 4 vCPU / 16 GiB) fits a new account’s Fargate quotas of 12 Spot and 12 On-Demand vCPUs; the admission task takes 4 On-Demand vCPUs. Larger workers (for example 16 vCPU / 64 GiB × 32) need the Fargate Spot vCPU resource count (L-36FBB829) and Fargate On-Demand vCPU resource count (L-3032A538) quotas raised first. A task larger than the quota is never placed.

After the first deploy

You never upload the website by hand. A site Lambda renders it from the store, uploads the files that changed and invalidates CloudFront:
  • during cdk deploy, whenever the Hub image changed (a failed render fails the deploy);
  • after each publish, advisory or Lemma Hub admission (the store bucket sends its writes to EventBridge).
To re-render by hand, run aws lambda invoke --function-name <SiteRendererName> /dev/stdout. Issue API tokens by putting items into the Tokens table: {token_hash: sha256(token), tenant, plan, quota}.