Skip to content

🎥 Make videos programmatically with React

role name

Jonny Burger25b78782a6d2
diff --git a/packages/lambda/src/api/create-function.ts b/packages/lambda/src/api/create-function.ts
index 0369b6cf81..d192f84a37 100644
--- a/packages/lambda/src/api/create-function.ts
+++ b/packages/lambda/src/api/create-function.ts
@@ -15,6 +15,7 @@ import {
} from '../defaults';
import {getCloudWatchLogsClient, getLambdaClient} from '../shared/aws-clients';
import {hostedLayers} from '../shared/hosted-layers';
+import {ROLE_NAME} from './iam-validation/suggested-policy';
export const createFunction = async ({
createCloudWatchLogGroup,
@@ -55,8 +56,7 @@ export const createFunction = async ({
},
FunctionName: functionName,
Handler: 'index.handler',
- // TODO: Give helpful suggestion if user did not create role
- Role: `arn:aws:iam::${accountId}:role/remotion-lambda-role`,
+ Role: `arn:aws:iam::${accountId}:role/${ROLE_NAME}`,
Runtime: 'nodejs14.x',
Description: 'Renders a Remotion video.',
MemorySize: memorySizeInMb,
diff --git a/packages/lambda/src/api/iam-validation/suggested-policy.ts b/packages/lambda/src/api/iam-validation/suggested-policy.ts
index c5dd16b4d0..98c74d4e85 100644
--- a/packages/lambda/src/api/iam-validation/suggested-policy.ts
+++ b/packages/lambda/src/api/iam-validation/suggested-policy.ts
@@ -36,6 +36,8 @@ const suggestedRolePolicy = {
export const getUserPolicy = () => JSON.stringify(suggestedPolicy, null, 2);
+export const ROLE_NAME = 'remotion-lambda-role';
+
/**
* @description Returns an inline JSON policy to be assigned to the 'remotion-lambda-role' role that needs to be created in your AWS account.
* @link https://remotion.dev/docs/lambda/getrolepolicy
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index 8d67b8ac99..09b776bb35 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -1,5 +1,7 @@
import {CliInternals} from '@remotion/cli';
+import {ROLE_NAME} from '../api/iam-validation/suggested-policy';
import {checkCredentials} from '../shared/check-credentials';
+import {DOCS_URL} from '../shared/docs-url';
import {parsedLambdaCli} from './args';
import {functionsCommand, FUNCTIONS_COMMAND} from './commands/functions';
import {policiesCommand, POLICIES_COMMAND} from './commands/policies/policies';
@@ -95,6 +97,22 @@ export const executeCommand = async (args: string[]) => {
await matchCommand(args);
} catch (err) {
const error = err as Error;
+ if (
+ error.message.includes(
+ 'The role defined for the function cannot be assumed by Lambda'
+ )
+ ) {
+ Log.error(
+ `
+The role "${ROLE_NAME}" does not exist in your AWS account or has the wrong policy assigned to it. Common reasons:
+- The name of the role is not "${ROLE_NAME}"
+- The policy is not exactly as specified in the setup guide
+
+Revisit ${DOCS_URL}/docs/lambda/setup and make sure you set up the role and role policy correctly. The original error message is:
+`.trim()
+ );
+ }
+
if (error.stack?.includes('AccessDenied')) {
// TODO: Explain permission problem
Log.error('PERMISSION PROBLEM PUT HELPFUL MESSAGE HERE');
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index 9cbd621f76..62f774311f 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -264,6 +264,7 @@ export type RenderMetadata = {
};
export type LambdaVersions =
+ | '2021-11-15'
| '2021-11-12'
| '2021-11-10'
| '2021-11-01'
@@ -283,7 +284,7 @@ export type LambdaVersions =
| '2021-06-23'
| 'n/a';
-export const CURRENT_VERSION: LambdaVersions = '2021-11-12';
+export const CURRENT_VERSION: LambdaVersions = '2021-11-15';
export type PostRenderData = {
cost: {