🎥 Make videos programmatically with React
`@remotion/lambda`: Add Remotion + Version tag when deploying function
Jonny Burgerf35637b7fbb6
diff --git a/packages/docs/docs/lambda/permissions.md b/packages/docs/docs/lambda/permissions.mdindex 6d0d560afc..5e5646c79b 100644--- a/packages/docs/docs/lambda/permissions.md+++ b/packages/docs/docs/lambda/permissions.md@@ -150,17 +150,19 @@ The following table is a breakdown of why Remotion Lambda requires the permissio</tr><tr><td>- <code>logs:InvokeAsync</code> <br/>- <code>logs:InvokeFunction</code> <br/>- <code>logs:DeleteFunction</code> <br/>- <code>logs:PutFunctionEventInvokeConfig</code> <br/>- <code>logs:CreateFunction</code> <br/>+ <code>lambda:InvokeAsync</code> <br/>+ <code>lambda:InvokeFunction</code> <br/>+ <code>lambda:DeleteFunction</code> <br/>+ <code>lambda:PutFunctionEventInvokeConfig</code> <br/>+ <code>lambda:CreateFunction</code> <br/>+ <code>lambda:PutRuntimeManagementConfig</code> <br/>+ <code>lambda:TagResource</code> <br/></td><td><code>{"arn:aws:lambda:*:*:function:remotion-render-*"}</code></td><td>- Allows to create, delete, invoke and configure functions (such as disabling automatic retries). Used by the CLI and the Node.JS APIS to set up, execute and teardown the infrastructure.+ Allows to create, delete, invoke and configure functions (such as disabling automatic retries). Used by the CLI and the Node.JS APIS to set up, execute and teardown the infrastructure. <code>lambda:TagResource</code> will optionally tag the functions</td></tr><tr>diff --git a/packages/lambda/src/api/create-function.ts b/packages/lambda/src/api/create-function.tsindex ebe31beeac..0f1a773171 100644--- a/packages/lambda/src/api/create-function.ts+++ b/packages/lambda/src/api/create-function.ts@@ -7,8 +7,10 @@ import {GetFunctionCommand,PutFunctionEventInvokeConfigCommand,PutRuntimeManagementConfigCommand,+ TagResourceCommand,} from '@aws-sdk/client-lambda';import {readFileSync} from 'node:fs';+import {VERSION} from 'remotion/version';import {LOG_GROUP_PREFIX} from '../defaults';import type {AwsRegion} from '../pricing/aws-regions';import {getCloudWatchLogsClient, getLambdaClient} from '../shared/aws-clients';@@ -68,7 +70,7 @@ export const createFunction = async ({const defaultRoleName = `arn:aws:iam::${accountId}:role/${ROLE_NAME}`;- const {FunctionName} = await getLambdaClient(region).send(+ const {FunctionName, FunctionArn} = await getLambdaClient(region).send(new CreateFunctionCommand({Code: {ZipFile: readFileSync(zipFile),@@ -89,6 +91,24 @@ export const createFunction = async ({},}),);++ try {+ await getLambdaClient(region).send(+ new TagResourceCommand({+ Resource: FunctionArn,+ Tags: {+ 'remotion-lambda': 'true',+ 'remotion-version': VERSION,+ },+ }),+ );+ } catch (err) {+ // Previous Lambda versions had no permission to tag the function+ if (!(err as Error).name.includes('AccessDenied')) {+ throw err;+ }+ }+await getLambdaClient(region).send(new PutFunctionEventInvokeConfigCommand({MaximumRetryAttempts: 0,diff --git a/packages/lambda/src/api/iam-validation/user-permissions.ts b/packages/lambda/src/api/iam-validation/user-permissions.tsindex bad9a33351..f78568a621 100644--- a/packages/lambda/src/api/iam-validation/user-permissions.ts+++ b/packages/lambda/src/api/iam-validation/user-permissions.ts@@ -75,6 +75,7 @@ export const requiredPermissions: {lambda.DeleteFunction,lambda.PutFunctionEventInvokeConfig,'lambda:PutRuntimeManagementConfig',+ lambda.TagResource,],resource: [`arn:aws:lambda:*:*:function:${RENDER_FN_PREFIX}*`],},