Nirmos
Platform setup

AWS S3 setup

Configure private media storage, IAM permissions, browser CORS, and retention.

Configure the same storage settings on API and runtime. The dashboard and public SDK need no AWS credentials. Missing storage configuration does not prevent unrelated routes from starting; image/media storage operations fail explicitly.

Bucket and IAM

Create a private general-purpose S3 bucket in your chosen region. Enable Block Public Access, Bucket owner enforced object ownership, and default SSE-S3 encryption. Do not enable public-read ACLs or public-write policies. Versioning is recommended; configure noncurrent-version expiration appropriate to your retention requirements.

Prefer IAM roles or workload credentials through the AWS default provider chain. If using access keys locally, provide both access key and secret, and the session token for temporary credentials. Never place them in NEXT_PUBLIC_* variables.

Attach an identity policy scoped to your bucket and the configured prefix. Replace YOUR_PRIVATE_BUCKET with your bucket name and adjust nirmos/ if changing S3_KEY_PREFIX:

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": ["s3:GetObject", "s3:GetObjectVersion", "s3:PutObject", "s3:DeleteObject", "s3:DeleteObjectVersion"],
    "Resource": ["arn:aws:s3:::YOUR_PRIVATE_BUCKET/nirmos/*"]
  }]
}

HeadObject uses GetObject permission; conditional promotion uses GetObject and PutObject. No bucket-wide ListBucket permission is required. Bucket policies should require TLS. If you require SSE-KMS, separately configure the role and key policy; this release relies on bucket encryption defaults.

Environment variables

VariableDefaultUsage
AWS_REGIONunsetBucket region; required for media
AWS_ACCESS_KEY_IDprovider chainOptional local access key
AWS_SECRET_ACCESS_KEYprovider chainOptional local secret
AWS_SESSION_TOKENunsetOptional temporary credential token
S3_BUCKETunsetPrivate storage bucket
S3_KEY_PREFIXnirmos/Server-generated object namespace
S3_UPLOAD_MAX_SIZE_MB20Asset size cap, configurable downward
S3_PRESIGNED_UPLOAD_TTL_SECONDS300Upload authorization lifetime; maximum 900
S3_PRESIGNED_DOWNLOAD_TTL_SECONDS900Download URL lifetime; maximum 3600
IMAGES_TIMEOUT_MS300000Image execution deadline; maximum 600000

AWS role-related provider-chain variables are forwarded through Turbo. The media client is lazy; storage readiness is checked when an operation needs it. Credential checks cannot guarantee that a later object write will succeed. A provider can incur charges before a storage permission/network failure is discovered.

Browser CORS

Set bucket CORS to your exact deployed dashboard origin. Replace the example below with the origin configured in API_CORS_ORIGINS; include http://localhost:3000 only for a bucket used in local development. Do not use a wildcard origin.

[{
  "AllowedOrigins": ["https://dashboard.example.com"],
  "AllowedMethods": ["POST", "GET", "HEAD"],
  "AllowedHeaders": ["Content-Type"],
  "ExposeHeaders": ["ETag", "x-amz-version-id"],
  "MaxAgeSeconds": 300
}]

CORS does not grant object access. Uploads require signed POST fields; downloads require signed GET URLs. Presigning exposes the required signing identifiers and temporary transport fields, never an AWS secret access key.

Deployment and maintenance

Use long-running Node for synchronous image generation. Configure API bridge and reverse-proxy deadlines above IMAGES_TIMEOUT_MS plus transfer time, response limits above the maximum base64 response, and at least 1 GiB process memory for the default bounded concurrency. Serverless function limits can interrupt this flow and are not the first-release deployment target.

Deploy generated Prisma artifacts and synchronize the MongoDB schema/indexes through your normal reviewed deployment procedure. MongoDB must support transactions. Run pnpm db:seed with the intended catalog scope to install image profiles; SEED_CATALOG_ONLY=1 skips unrelated fixtures.

Add an S3 lifecycle rule expiring objects under nirmos/staging/ after one day. Staged files can be recreated while their upload authorization remains valid, but cannot replace final assets. If versioning is enabled, include noncurrent staging versions and expired delete markers in lifecycle cleanup. Do not expire nirmos/media/ independently of database references.

Schedule the bounded operator command with the API environment:

pnpm --filter @nirmos/api media:maintenance

It marks interrupted generations older than 15 minutes failed, expires incomplete uploads, and retries up to 50 stored cleanup manifests per invocation. Run repeatedly for a backlog. It does not submit generation jobs. Preserve failure diagnostics and monitor FAILED generations and cleanup backlog through database/operations tooling.

Media uploads · Image generation limits

Opt-in database integration tests use IMAGES_INTEGRATION_MONGO_URL pointing only to an isolated nirmos-images-test replica-set database. Normal tests do not use live AWS or provider credentials.

On this page