How to Set Up Serverless Rendering with Remotion and AWS Lambda: A Complete Guide
Deploy your Remotion video pipeline to AWS Lambda using the @remotion/lambda package to create a fully serverless architecture that scales automatically without managing servers.
Serverless rendering with Remotion and AWS Lambda transforms your video generation workflow into an on-demand service that runs only when needed. The remotion-dev/remotion repository provides a complete Lambda integration through dedicated packages that handle deployment, execution, and monitoring of video renders in the AWS cloud.
Architecture of Serverless Rendering with Remotion and AWS Lambda
The serverless architecture consists of three core components that work together to process video renders without persistent infrastructure.
Lambda Function Runtime
The Lambda function is a Node.js runtime that executes the actual video rendering. According to the source code in packages/lambda/src/index.ts, this function bundles Chrome headless and the Remotion rendering engine to execute video generation inside the AWS environment. The @remotion/lambda package provides the deployFunction() helper to provision this runtime with specific memory and timeout configurations.
S3 Site Hosting
Static assets from your Remotion project—including compiled JavaScript bundles, HTML entry points, and media files—must reside in S3. The deploySite() function in packages/lambda-client/src/index.ts handles uploading your entry point to a versioned S3 bucket, returning a serve URL that the Lambda function fetches at runtime to load your composition code.
IAM Role and User
Security relies on two IAM entities created in your AWS account: the remotion-lambda-role (attached to the Lambda function execution) and the remotion-user (owning the access keys used by the CLI and Node APIs). As documented in packages/docs/docs/lambda/setup.mdx (lines 18-70), you generate policy JSON via the CLI commands npx remotion lambda policies role and npx remotion lambda policies user, then apply these policies in the AWS console.
Prerequisites and Installation
Install the Lambda packages into your existing Remotion project:
npm install @remotion/lambda
# For backend integration
npm install @remotion/lambda/client
The @remotion/lambda package contains deployment utilities and the runtime definition, while @remotion/lambda/client provides the typed Node.js SDK for rendering workflows.
Step-by-Step Setup Guide
Configure AWS IAM Permissions
Generate the required IAM policies using the Remotion CLI as implemented in packages/cli/src/lambda-command.ts:
# Generate the trust policy for the Lambda execution role
npx remotion lambda policies role
# Generate the user policy for CLI/API access
npx remotion lambda policies user
Create the remotion-lambda-role in AWS IAM and attach the generated role policy. Create the remotion-user, attach the user policy, and generate an access key pair.
Validate IAM Configuration
Store the credentials in your environment variables:
REMOTION_AWS_ACCESS_KEY_ID=your_access_key_id
REMOTION_AWS_SECRET_ACCESS_KEY=your_secret_access_key
Validate the setup before proceeding:
npx remotion lambda policies validate
Deploy the Lambda Function
Deploy using the CLI:
npx remotion lambda functions deploy
Or programmatically using the Node.js API from packages/lambda-client/src/index.ts:
import {deployFunction} from '@remotion/lambda';
const {functionName} = await deployFunction({
region: 'us-east-1',
timeoutInSeconds: 120,
memorySizeInMb: 2048,
createCloudWatchLogGroup: true,
});
console.log('Deployed function:', functionName);
Deploy Your Remotion Site to S3
Deploy your bundled composition code via CLI:
npx remotion lambda sites create src/index.ts --site-name=my-video
Or programmatically:
import path from 'path';
import {getOrCreateBucket, deploySite} from '@remotion/lambda';
const {bucketName} = await getOrCreateBucket({region: 'us-east-1'});
const {serveUrl} = await deploySite({
bucketName,
entryPoint: path.resolve(process.cwd(), 'src/index.ts'),
region: 'us-east-1',
siteName: 'my-video',
});
console.log('Site URL:', serveUrl);
Render Videos via Lambda
Execute a render using the CLI:
npx remotion lambda render <serve-url> <composition-id>
For backend integration, use the client SDK:
import {
getFunctions,
renderMediaOnLambda,
getRenderProgress,
} from '@remotion/lambda/client';
const functions = await getFunctions({
region: 'us-east-1',
compatibleOnly: true,
});
const functionName = functions[0].functionName;
const {renderId, bucketName} = await renderMediaOnLambda({
region: 'us-east-1',
functionName,
serveUrl: '<serve-url>',
composition: '<composition-id>',
inputProps: {},
codec: 'h264',
imageFormat: 'jpeg',
maxRetries: 1,
framesPerLambda: 20,
privacy: 'public',
});
while (true) {
await new Promise(r => setTimeout(r, 1000));
const progress = await getRenderProgress({
renderId,
bucketName,
functionName,
region: 'us-east-1',
});
if (progress.done) {
console.log('Render finished! File:', progress.outputFile);
break;
}
if (progress.fatalErrorEncountered) {
console.error('Render failed:', progress.errors);
break;
}
}
Key Implementation Details
Version-Locked Functions
Each Lambda function is baked with a specific Remotion version to ensure consistent rendering behavior. When upgrading Remotion, you must redeploy the function using npx remotion lambda functions deploy or the deployFunction() API. Old functions remain available but should be cleaned up once active renders complete.
Stateless Rendering Architecture
The Lambda function operates as a stateless worker according to the implementation in packages/lambda/src/index.ts. It receives a serve URL, pulls the compiled JavaScript bundle from S3, runs Chrome headless inside the Lambda runtime, and streams the output back to S3. No persistent storage is required on the function itself, making the architecture inherently scalable and fault-tolerant.
Concurrency and Quotas
AWS imposes a per-region concurrent invocation quota (default 1000). A single Remotion render can utilize up to 200 concurrent Lambda invocations, meaning the quota directly limits how many videos you can render in parallel. Check your current quota using npx remotion lambda quotas and request increases through AWS Support if you need higher throughput.
Summary
- Serverless rendering with Remotion and AWS Lambda eliminates infrastructure management by executing video generation in ephemeral Lambda functions that scale automatically.
- The architecture requires three components: a Lambda function (runtime), an S3 bucket (static assets), and IAM roles (security permissions).
- Use
@remotion/lambdafor deployment operations and@remotion/lambda/clientfor rendering workflows in Node.js applications. - Always redeploy Lambda functions when upgrading Remotion versions to maintain compatibility and consistent rendering behavior.
- Monitor AWS concurrency quotas carefully, as each video render can consume up to 200 parallel Lambda invocations.
Frequently Asked Questions
What AWS region should I use for Remotion Lambda?
Choose a region geographically close to your users or infrastructure to minimize latency. The us-east-1 region is commonly used and well-supported by Remotion. When deploying, specify the same region consistently across deployFunction(), deploySite(), and renderMediaOnLambda() calls to ensure all components communicate within the same AWS region.
How do I update the Remotion Lambda function when upgrading versions?
Lambda functions are version-locked to ensure consistent rendering behavior. After upgrading the @remotion/lambda package in your project, run npx remotion lambda functions deploy to provision a new function with the updated runtime. Old functions remain available for active renders but should be removed using npx remotion lambda functions rm once all renders complete to avoid confusion and reduce costs.
What is the maximum video duration supported by Remotion Lambda?
Video duration is limited by the Lambda function timeout (maximum 900 seconds or 15 minutes) and memory allocation. For longer videos, increase the timeoutInSeconds parameter up to the AWS Lambda limit when calling deployFunction(), or split the composition into shorter segments that can be rendered in parallel and concatenated afterward using Remotion's stitching capabilities.
How does Remotion Lambda handle concurrent video renders?
Each video render distributes frames across multiple Lambda invocations (up to 200 per render). AWS imposes a per-region concurrent invocation quota (default 1000), which directly limits how many videos you can render in parallel. Check your current quota using npx remotion lambda quotas and request increases through AWS Support if your application requires higher throughput for simultaneous video generation.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →