AWS Lambda
Build the server as an AWS Lambda handler with Amazon S3 storage, use the function's role for credentials, and schedule the expiry task.
Build the handler
NITRO_PRESET=aws_lambda pnpm build
- Package the contents of
apps/api/.output/serveras the function code. - Choose a Node.js runtime, and set the handler to
index.handler. - Give the function an HTTPS endpoint that
turbocan reach, such as a Lambda function URL or an API Gateway HTTP API.
Configure storage
Set these variables on the function:
TURBO_TOKEN=<your token>
S3_BUCKET=my-turborepo-cache
S3_ENDPOINT=https://s3.us-east-1.amazonaws.com
Leave the S3_* keys and S3_REGION unset to use the function’s execution role. Lambda puts the role’s credentials in AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN, and its region in AWS_REGION, and the server reads all four. The role needs s3:GetObject, s3:PutObject, s3:DeleteObject, and s3:ListBucket on the bucket.
The expiry task
The Lambda build doesn’t schedule the expiry task. Call POST /internal/delete-expired-objects once a day from any scheduler that can send an HTTPS request with a header, such as a CI cron job. Retention and expiry shows the request.