Skip to content

🎥 Make videos programmatically with React

Docs: Fix custom Lambda destination bucket permissions

Jonny Burger03bd92b3b3c5
diff --git a/packages/docs/docs/lambda/without-iam/index.mdx b/packages/docs/docs/lambda/without-iam/index.mdx
index 1cabd77604..e72ba52928 100644
--- a/packages/docs/docs/lambda/without-iam/index.mdx
+++ b/packages/docs/docs/lambda/without-iam/index.mdx
@@ -34,9 +34,9 @@ The steps below provide authorization for the Lambda function to execute `render
- Click on JSON
- Copy the JSON policy template below:
<details>
- <summary>Show full role permissions JSON file for latest Remotion Lambda version</summary>
- <UserPolicy />
- </details>
+ <summary>Show full role permissions JSON file for latest Remotion Lambda version</summary>
+ <UserPolicy />
+</details>
- Click next. On the tags page, you don't need to fill in anything. Click next again.
- Give the policy the name `remotion-executionrole-policy`. The other fields can be left as they are.
@@ -88,7 +88,7 @@ const {bucketName, renderId} = await renderMediaOnLambda({
});
```
-In the example above, the `renderMediaOnLambda()` is configured to output the rendered video to `transfer-to-this-bucket-after-render` bucket. The following steps allow Lambda to move the file to another bucket.
+In the example above, `renderMediaOnLambda()` is configured to output the rendered video to the `output-bucket` bucket. The following steps grant the Remotion Lambda execution role access to this bucket.
### Steps
@@ -104,15 +104,22 @@ In the example above, the `renderMediaOnLambda()` is configured to output the re
- Click "Create inline policy"
- Click the "JSON" tab
-Add a policy statement similar to the one below, which is defining the bucket Lambda needs to transfer the rendered video to.
+Add the policy below to grant `s3:PutObject` and `s3:GetObject` on the destination bucket's objects, and `s3:ListBucket` on the bucket itself.
-```json
+Remotion checks whether the output file exists using an S3 `HeadObject` request. This requires `s3:GetObject`. The `s3:ListBucket` permission lets S3 return `404 Not Found` while the output file does not exist, instead of `403 Forbidden`. See the [S3 HeadObject permissions](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html).
+
+```json title="Destination bucket policy"
{
"Version": "2012-10-17",
"Statement": [
{
- "Action": ["s3:PutObject"],
- "Resource": ["arn:aws:s3:::{bucketname}", "arn:aws:s3:::{bucketname}/*"],
+ "Action": ["s3:PutObject", "s3:GetObject"],
+ "Resource": ["arn:aws:s3:::{bucketname}/*"],
+ "Effect": "Allow"
+ },
+ {
+ "Action": ["s3:ListBucket"],
+ "Resource": ["arn:aws:s3:::{bucketname}"],
"Effect": "Allow"
}
]