{"record":{"id":"a6bf2aabea7656e8","repo":"remotion-dev/remotion","slug":"failed-to-update-layers-for-function-functionnam","errorCode":null,"errorMessage":"Failed to update Layers for function ${functionName}: ${configuration.StateReason ?? configuration.LastUpdateStatusReason ?? 'Unknown reason'}","messagePattern":"Failed to update Layers for function (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lambda/src/api/create-function.ts","lineNumber":185,"sourceCode":"\t\t\t{indent: false, logLevel},\n\t\t\t`Updating Layers for function ${functionName}`,\n\t\t);\n\t\tawait lambdaClient.send(\n\t\t\tnew UpdateFunctionConfigurationCommand({\n\t\t\t\tFunctionName: functionName,\n\t\t\t\tLayers: layers,\n\t\t\t}),\n\t\t);\n\n\t\twhile (true) {\n\t\t\tconst configuration = await lambdaClient.send(\n\t\t\t\tnew GetFunctionConfigurationCommand({FunctionName: functionName}),\n\t\t\t);\n\t\t\tif (\n\t\t\t\tconfiguration.State === 'Failed' ||\n\t\t\t\tconfiguration.LastUpdateStatus === 'Failed'\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to update Layers for function ${functionName}: ${configuration.StateReason ?? configuration.LastUpdateStatusReason ?? 'Unknown reason'}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tconfiguration.State === 'Active' &&\n\t\t\t\tconfiguration.LastUpdateStatus !== 'InProgress'\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tsetTimeout(resolve, 1000);\n\t\t\t});\n\t\t}\n\n\t\treturn {FunctionName: functionName};\n\t}","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/remotion-dev/remotion/blob/10db9de07356446fb0edb3c3ae211369b693d18b/packages/lambda/src/api/create-function.ts#L167-L203","documentation":"When deploying with Remotion Lambda's createFunction() over an EXISTING function (alreadyCreated) with custom layer ARNs, the client updates the function's Layers via UpdateFunctionConfiguration and polls GetFunctionConfiguration until stable. If AWS reports State 'Failed' or LastUpdateStatus 'Failed', this error is thrown with the StateReason AWS provided - the layer update was rejected or broke the function.","triggerScenarios":"Calling `remotion lambda functions create` (or deployFunction) twice with --custom-role-arn/layer ARNs where the function already exists and the layer list changed, and AWS marks the layer update as Failed. Only happens in the alreadyCreated + customLayerArns path (packages/lambda/src/api/create-function.ts:170-188).","commonSituations":"Custom layer ARN deleted or version-number no longer exists; layer built for x86_64 while Remotion functions use arm64; layer incompatible with the nodejs24.x runtime; layer exceeds size limits; layer lives in a different region/account; IAM role lacking lambda:UpdateFunctionConfiguration leading AWS to report a failed state.","solutions":["Read the StateReason in the message - it is AWS's own explanation (e.g. layer not found, incompatible architecture)","Verify each layer ARN exists and matches the runtime: `aws lambda get-layer-version --layer-name NAME --version-number N --region REGION` (check CompatibleRuntimes includes nodejs24.x and CompatibleArchitectures includes arm64)","Delete the function and redeploy fresh: `npx remotion lambda functions rm FUNCTION_NAME` then re-run `functions create` - a clean create skips the failing update path","Ensure layer ARNs are in the same region and account as the function","Check the deploy role has lambda:GetFunctionConfiguration, lambda:UpdateFunctionConfiguration and lambda:PutFunctionConfiguration* permissions"],"exampleFix":"# before - stale layer ARN on an existing function\nnpx remotion lambda functions create \\\n  --layer-arns arn:aws:lambda:eu-central-1:123456789:layer:my-layer:1\n\n# after - verify the layer, then recreate the function\naws lambda get-layer-version-by-arn \\\n  --arn arn:aws:lambda:eu-central-1:123456789:layer:my-layer:3\nnpx remotion lambda functions rm remotion-render-3-3-0-\nnpx remotion lambda functions create \\\n  --layer-arns arn:aws:lambda:eu-central-1:123456789:layer:my-layer:3","handlingStrategy":"retry","validationCode":"# Before deploying over an existing function, confirm every layer ARN resolves\n# and matches runtime/architecture\nfor arn in $LAYER_ARNS; do\n  aws lambda get-layer-version-by-arn --arn \"$arn\" --region \"$REGION\" \\\n    --query '{runtimes: CompatibleRuntimes, archs: CompatibleArchitectures}' --output text\n  # expect: nodejs24.x (or similar)  arm64\ndone","typeGuard":null,"tryCatchPattern":"// Wrap deployFunction and surface StateReason, then retry after correction\ntry {\n  await deployFunction({/* ... */});\n} catch (err) {\n  if (\n    err instanceof Error &&\n    err.message.startsWith('Failed to update Layers for function')\n  ) {\n    console.error('Layer update rejected by AWS:', err.message);\n    // fix layer ARNs (see StateReason), optionally delete + recreate the function, retry\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Validate layer ARNs with aws lambda get-layer-version-by-arn before every deploy","Build custom layers for arm64 and a nodejs runtime compatible with the function","Pin exact layer versions and keep them in the same region/account as the function","Prefer deleting and recreating functions when layer sets change substantially"],"tags":["aws","lambda","layers","deployment","remotion","iam"],"backgroundTag":"lambda-layer-update-failed","analyzedSha":"10db9de07356446fb0edb3c3ae211369b693d18b","analyzedAt":"2026-08-22T21:45:17.748Z","contentChangedAt":"2026-08-22T21:45:17.748Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}