Skip to content

🎥 Make videos programmatically with React

set retries to 0

Jonny Burger377d661eaec5
diff --git a/packages/docs/docs/lambda-changelog.md b/packages/docs/docs/lambda-changelog.md
index 3c14a9fce4..4a011eecfd 100644
--- a/packages/docs/docs/lambda-changelog.md
+++ b/packages/docs/docs/lambda-changelog.md
@@ -14,6 +14,12 @@ Keep track of changes to the APIs of Remotion Lambda here.
1. Redeploy your function: `npx remotion lambda functions deploy`
1. Migrate according to the changelog below:
+## Unreleased
+
+- **Breaking change**: Update your AWS User policy to include the `lambda:PutFunctionEventInvokeConfig` permission. We will now prevent AWS from retrying failed Lambda functions and only use our own retry system.
+
+Read [Step 4](https://remotion-lambda-alpha.netlify.app/docs/lambda/setup#4-create-a-user) of the setup guide and update the user with the newest policy (`npx remotion lambda policies user`).
+
## November 1st, 2021
Version hash: `3.0.0-lambda.57+d1dd7ce77`
diff --git a/packages/lambda/src/api/create-function.ts b/packages/lambda/src/api/create-function.ts
index 5e8ee507ca..a53e77c7d0 100644
--- a/packages/lambda/src/api/create-function.ts
+++ b/packages/lambda/src/api/create-function.ts
@@ -1,6 +1,10 @@
-import {CreateFunctionCommand} from '@aws-sdk/client-lambda';
+import {
+ CreateFunctionCommand,
+ PutFunctionEventInvokeConfigCommand,
+} from '@aws-sdk/client-lambda';
import {readFileSync} from 'fs';
import {AwsRegion} from '..';
+import {Log} from '../cli/log';
import {getLambdaClient} from '../shared/aws-clients';
import {hostedLayers} from '../shared/hosted-layers';
@@ -37,5 +41,19 @@ export const createFunction = async ({
),
})
);
+ // TODO: Remove try catch in future versions
+ try {
+ await getLambdaClient(region).send(
+ new PutFunctionEventInvokeConfigCommand({
+ MaximumRetryAttempts: 0,
+ FunctionName,
+ })
+ );
+ } catch (err) {
+ Log.warn(
+ '\nWe now require the lambda:PutFunctionEventInvokeConfig permissions for your user. Please run `npx remotion lambda policies user` update your user policy. This will be required for the final version of Remotion Lambda.'
+ );
+ }
+
return {FunctionName};
};
diff --git a/packages/lambda/src/api/iam-validation/required-permissions.ts b/packages/lambda/src/api/iam-validation/required-permissions.ts
index 4ada5fe4b6..1764d98c3b 100644
--- a/packages/lambda/src/api/iam-validation/required-permissions.ts
+++ b/packages/lambda/src/api/iam-validation/required-permissions.ts
@@ -48,6 +48,7 @@ export const requiredPermissions: {
lambda.InvokeFunction,
lambda.CreateFunction,
lambda.DeleteFunction,
+ lambda.PutFunctionEventInvokeConfig,
],
resource: [`arn:aws:lambda:*:*:function:${RENDER_FN_PREFIX}*`],
},