Skip to content

🎥 Make videos programmatically with React

better error message for UnrecognizedClientException (Lambda)

Jonny Burgerafdd2b855578
diff --git a/packages/docs/docs/lambda/troubleshooting/unrecognizedclientexception.md b/packages/docs/docs/lambda/troubleshooting/unrecognizedclientexception.md
new file mode 100644
index 0000000000..f3ac029e44
--- /dev/null
+++ b/packages/docs/docs/lambda/troubleshooting/unrecognizedclientexception.md
@@ -0,0 +1,23 @@
+---
+id: unrecognizedclientexception
+title: UnrecognizedClientException
+---
+
+If you got a permission error while calling [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda) or [`renderStillOnLambda()`](/docs/lambda/renderstillonlambda):
+
+```txt
+UnrecognizedClientException: The AWS credentials provided were probably mixed up.
+```
+
+it means that the AWS credentials were correct, but don't allow access to a certain resource.
+
+## Most common cause: Calling a Remotion function inside a serverless function
+
+When calling render inside an AWS Lambda function or a Vercel serverless function, that function already has it's own `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables set. However, these are from AWS itself and are different from the variables that Remotion uses to invoke serverless functions.
+
+To avoid that conflict, you can change the name of the environment variables you set:
+
+- Rename `AWS_ACCESS_KEY_ID` to `REMOTION_AWS_ACCESS_KEY_ID`
+- Rename `AWS_SECRET_ACCESS_KEY` to `REMOTION_AWS_SECRET_ACCESS_KEY`
+
+If both are set, Remotion will prefer the environment variables that are prefixed with `REMOTION_`, which should separate the two different credentials nicely.
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index c05fcbe90e..e6f53785d0 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -64,6 +64,7 @@ module.exports = {
items: [
"lambda/troubleshooting/permissions",
"lambda/troubleshooting/rate-limit",
+ "lambda/troubleshooting/unrecognizedclientexception",
],
},
"lambda/changelog",
diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.ts
index 1a530b8eee..3a6da4e633 100644
--- a/packages/lambda/src/api/render-media-on-lambda.ts
+++ b/packages/lambda/src/api/render-media-on-lambda.ts
@@ -102,40 +102,50 @@ export const renderMediaOnLambda = async ({
validateFramesPerLambda(framesPerLambda ?? null);
validateDownloadBehavior(downloadBehavior);
const realServeUrl = await convertToServeUrl(serveUrl, region);
- const res = await callLambda({
- functionName,
- type: LambdaRoutines.start,
- payload: {
- framesPerLambda: framesPerLambda ?? null,
- composition,
- serveUrl: realServeUrl,
- inputProps,
- codec: actualCodec,
- imageFormat,
- crf,
- envVariables,
- pixelFormat,
- proResProfile,
- quality,
- maxRetries,
- privacy,
- logLevel: logLevel ?? 'info',
- frameRange: frameRange ?? null,
- outName: outName ?? null,
- timeoutInMilliseconds: timeoutInMilliseconds ?? 30000,
- chromiumOptions: chromiumOptions ?? {},
- scale: scale ?? 1,
- everyNthFrame: everyNthFrame ?? 1,
- numberOfGifLoops: numberOfGifLoops ?? 0,
- concurrencyPerLambda: concurrencyPerLambda ?? 1,
- downloadBehavior: downloadBehavior ?? {type: 'play-in-browser'},
- },
- region,
- });
- return {
- renderId: res.renderId,
- bucketName: res.bucketName,
- };
+ try {
+ const res = await callLambda({
+ functionName,
+ type: LambdaRoutines.start,
+ payload: {
+ framesPerLambda: framesPerLambda ?? null,
+ composition,
+ serveUrl: realServeUrl,
+ inputProps,
+ codec: actualCodec,
+ imageFormat,
+ crf,
+ envVariables,
+ pixelFormat,
+ proResProfile,
+ quality,
+ maxRetries,
+ privacy,
+ logLevel: logLevel ?? 'info',
+ frameRange: frameRange ?? null,
+ outName: outName ?? null,
+ timeoutInMilliseconds: timeoutInMilliseconds ?? 30000,
+ chromiumOptions: chromiumOptions ?? {},
+ scale: scale ?? 1,
+ everyNthFrame: everyNthFrame ?? 1,
+ numberOfGifLoops: numberOfGifLoops ?? 0,
+ concurrencyPerLambda: concurrencyPerLambda ?? 1,
+ downloadBehavior: downloadBehavior ?? {type: 'play-in-browser'},
+ },
+ region,
+ });
+ return {
+ renderId: res.renderId,
+ bucketName: res.bucketName,
+ };
+ } catch (err) {
+ if ((err as Error).stack?.includes('UnrecognizedClientException')) {
+ throw new Error(
+ 'UnrecognizedClientException: The AWS credentials provided were probably mixed up. Learn how to fix this issue here: https://remotion.dev/docs/lambda/troubleshooting/unrecognizedclientexception'
+ );
+ }
+
+ throw err;
+ }
};
/**
diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.ts
index dfd5777862..02a3c7de1e 100644
--- a/packages/lambda/src/api/render-still-on-lambda.ts
+++ b/packages/lambda/src/api/render-still-on-lambda.ts
@@ -75,34 +75,44 @@ export const renderStillOnLambda = async ({
downloadBehavior,
}: RenderStillOnLambdaInput): Promise<RenderStillOnLambdaOutput> => {
const realServeUrl = await convertToServeUrl(serveUrl, region);
- const res = await callLambda({
- functionName,
- type: LambdaRoutines.still,
- payload: {
- composition,
- serveUrl: realServeUrl,
- inputProps,
- imageFormat,
- envVariables,
- quality,
- maxRetries: maxRetries ?? DEFAULT_MAX_RETRIES,
- frame: frame ?? 0,
- privacy,
- attempt: 1,
- logLevel: logLevel ?? 'info',
- outName: outName ?? null,
- timeoutInMilliseconds: timeoutInMilliseconds ?? 30000,
- chromiumOptions: chromiumOptions ?? {},
- scale: scale ?? 1,
- downloadBehavior: downloadBehavior ?? {type: 'play-in-browser'},
- },
- region,
- });
- return {
- estimatedPrice: res.estimatedPrice,
- url: res.output,
- sizeInBytes: res.size,
- bucketName: res.bucketName,
- renderId: res.renderId,
- };
+ try {
+ const res = await callLambda({
+ functionName,
+ type: LambdaRoutines.still,
+ payload: {
+ composition,
+ serveUrl: realServeUrl,
+ inputProps,
+ imageFormat,
+ envVariables,
+ quality,
+ maxRetries: maxRetries ?? DEFAULT_MAX_RETRIES,
+ frame: frame ?? 0,
+ privacy,
+ attempt: 1,
+ logLevel: logLevel ?? 'info',
+ outName: outName ?? null,
+ timeoutInMilliseconds: timeoutInMilliseconds ?? 30000,
+ chromiumOptions: chromiumOptions ?? {},
+ scale: scale ?? 1,
+ downloadBehavior: downloadBehavior ?? {type: 'play-in-browser'},
+ },
+ region,
+ });
+ return {
+ estimatedPrice: res.estimatedPrice,
+ url: res.output,
+ sizeInBytes: res.size,
+ bucketName: res.bucketName,
+ renderId: res.renderId,
+ };
+ } catch (err) {
+ if ((err as Error).stack?.includes('UnrecognizedClientException')) {
+ throw new Error(
+ 'UnrecognizedClientException: The AWS credentials provided were probably mixed up. Learn how to fix this issue here: https://remotion.dev/docs/lambda/troubleshooting/unrecognizedclientexception'
+ );
+ }
+
+ throw err;
+ }
};