π₯ Make videos programmatically with React
code review fixes
Alex Fernandez34e2a846a77b
diff --git a/packages/docs/docs/lambda/serverlesslambdasetup.md b/packages/docs/docs/lambda/examplesetupwithoutiamuser.mdsimilarity index 84%rename from packages/docs/docs/lambda/serverlesslambdasetup.mdrename to packages/docs/docs/lambda/examplesetupwithoutiamuser.mdindex a223f7932f..9917562449 100644--- a/packages/docs/docs/lambda/serverlesslambdasetup.md+++ b/packages/docs/docs/lambda/examplesetupwithoutiamuser.md@@ -1,14 +1,15 @@----image: /generated/articles-docs-lambda-serverlesslambdasetup.png-id: serverlesslambdasetup-title: Serverless lambda setup-slug: /lambda/serverless-lambdas-setup+id: examplesetupwithoutiamuser+title: Example setup without IAM user+slug: /lambda/example-setup-without-iam-usercrumb: "Lambda"++---import Tabs from '@theme/Tabs';import TabItem from '@theme/TabItem';-This is a follow up write up for a serverless function from [lamdbda permissions](/docs/lambda/lambda-role-permissions).+This is a follow up write up for the serverless function from [using lambda without IAM user](/docs/lambda/using-lambda-without-iam-user).### Prequisites- Make sure that you're local AWS profile is able to deploy to AWS.@@ -16,7 +17,7 @@ This is a follow up write up for a serverless function from [lamdbda permissions### Setup#### 1. Clone or download the project-Project is located inside the [`remotion project`](https://github.com/alexfernandez803/example-lambda)+ Project is located inside the [`reference project`](https://github.com/alexfernandez803/example-lambda)#### 2. Install dependencies@@ -98,7 +99,7 @@ cdk-stack: deploying... [1/1]β¨ Deployment time: 1.39s```-### Output+ Output```bashOutputs:@@ -120,11 +121,11 @@ This will delete the function, in case it's not needed anymore.npx aws-cdk destroy```-### Lamdbda role-The CDK creates an IAM role named `remotionLambdaServerlessRole` which needs the remotion policy[setup](/docs/lambda/lambdarolepermissions).+## Lamdbda role+The CDK creates an IAM role named `remotionLambdaServerlessRole` which needs the remotion policy[setup](/docs/lambda/usinglambdawithoutiamuser).-### Test your endpoint+## Test your endpointThe API is secured by Cognito which requires an authorization token.In order to test the API need to do the steps below, just in case you still don't have frontend.@@ -155,7 +156,7 @@ aws cognito-idp initiate-auth \--client-id YOUR_USER_POOL_CLIENT_ID```-YOUR_USER_POOL_CLIENT_ID and YOUR_USER_POOL_ID are part of CDK [output](/docs/lambda/serverless-lambdas-setup#output).+YOUR_USER_POOL_CLIENT_ID and YOUR_USER_POOL_ID are part of CDK [output](/docs/lambda/examplesetupwithoutiamuser#output).Output```bash@@ -192,12 +193,12 @@ That's it, you now have an API to invoke rendering of video.Don't allow the lambda function to be called by an `unauthenticated` user. And the lambda function uses CDK 2 which is actively on development which may break in the future.:::warn-### Next Steps+## Next Steps- Customize the lambda [`function`](https://github.com/alexfernandez803/example-lambda/blob/main/src/render-function/index.ts) so that the rendered video will be moved to another directory.-- Try assigning the remotion [role](/docs/lambda/lambda-role-permissions#1--create-role-policy) via CDK [`code`](https://github.com/alexfernandez803/example-lambda/blob/main/lib/remotion-cdk-starter-stack.ts).-- Add request parameters to the lambda function as input parameters for[`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda).+- Try assigning the remotion [role](/docs/lambda/using-lambda-without-iam-user#1--create-role-policy) via CDK [`code`](https://github.com/alexfernandez803/example-lambda/blob/main/lib/remotion-cdk-starter-stack.ts).+- Add request parameters to the lambda function as input parameters for [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda).## See also-- [Lambda permissions](/docs/lambda/lambdarolepermissions)+- [Using lambda without IAM user](/docs/lambda/using-lambda-without-iam-user)- [Permissions](/docs/lambda/permissions)- [Some code are borrowed from bobbyhadz.com](https://bobbyhadz.com/blog/aws-cdk-api-authorizer)\ No newline at end of filediff --git a/packages/docs/docs/lambda/lambdarolepermissions.md b/packages/docs/docs/lambda/usinglambdawithoutiamuser.mdsimilarity index 75%rename from packages/docs/docs/lambda/lambdarolepermissions.mdrename to packages/docs/docs/lambda/usinglambdawithoutiamuser.mdindex c0a6e4e808..6c9b6fe2f9 100644--- a/packages/docs/docs/lambda/lambdarolepermissions.md+++ b/packages/docs/docs/lambda/usinglambdawithoutiamuser.md@@ -1,8 +1,8 @@----image: /generated/articles-docs-lambda-lambda-role-permissions.png-id: lambdarolepermissions-title: Lambda permissions-slug: /lambda/lambda-role-permissions+image: /generated/articles-docs-lambda-usinglambdawithoutiamuser.png+id: usinglambdawithoutiamuser+title: Using Lambda without IAM user+slug: /lambda/using-lambda-without-iam-usercrumb: "Lambda"---@@ -16,12 +16,12 @@ There also some that has requirements to execute the [`renderMediaOnLambda()`](/The steps below provides authorization to the lambda function to execute `renderMediaOnLambda()` without permission issues.-#### Prerequisites-1. This assumes that you have deployed a `lambda` function running in AWS. An example is created in [`here`](https://github.com/remotion-dev/remotion/tree/main/packages/example-lambda) using [`CDK`](https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-typescript.html) to give you an idea how to call [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda) inside another a lambda function, the function is triggered by [API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html). This assumes that you have knowledge on using [`CDK`](https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-typescript.html), a [write up](/docs/lambda/serverless-lambdas-setup) for this is also created for anyone to follow.+## Prerequisites+1. This assumes that you have deployed a `lambda` function running in AWS. An example is created in [`here`](https://github.com/alexfernandez803/example-lambda) using [`CDK`](https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-typescript.html) to give you an idea how to call [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda) inside another a lambda function, the function is triggered by [API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html). This assumes that you have knowledge on using [`CDK`](https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-typescript.html), a [write up](/docs/lambda/examplesetupwithoutiamuser) for this is also created for anyone to follow.2. Lambda execution role assigned to the lambda3. User Policy [user permissions](/docs/lambda/permissions#user-permissions).-### Setup+## Setup#### 1. Create role policy- Go to AWS account IAM Policies section@@ -50,26 +50,26 @@ This activity can be also applied to other AWS compute services such as `EC2`, `## OptionalIf you want to move the video to another s3 bucket when the video is rendered, the `lambda` also needs a permission to do so into the new bucket.-#### Example-```ts twoslash-// @module: esnext-// @target: es2017-// ---cut-----import { renderMediaOnLambda } from "@remotion/lambda/client";--const { bucketName, renderId } = await renderMediaOnLambda({- region: "us-east-1",- functionName: "remotion-render-bds9aab",- composition: "MyVideo",- serveUrl:- "https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",- codec: "h264",- outName: "transfer-to-this-bucket-after-render/the-filename.mp4",-});-```--From the example above, the `renderMediaOnLambda()` is configured to output the video to `transfer-to-this-bucket-after-render` bucket. The steps to allows the lambda to move the file to the other bucket, which is similar to [this](/docs/lambda/trigger-lambda-from-aws#setup).+ #### Example+ ```ts twoslash+ // @module: esnext+ // @target: es2017+ // ---cut---++ import { renderMediaOnLambda } from "@remotion/lambda/client";++ const { bucketName, renderId } = await renderMediaOnLambda({+ region: "us-east-1",+ functionName: "remotion-render-bds9aab",+ composition: "MyVideo",+ serveUrl:+ "https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",+ codec: "h264",+ outName: "transfer-to-this-bucket-after-render/the-filename.mp4",+ });+ ```++ From the example above, the `renderMediaOnLambda()` is configured to output the video to `transfer-to-this-bucket-after-render` bucket. The steps to allows the lambda to move the file to the other bucket, which is similar to [this](/docs/lambda/trigger-lambda-from-aws#setup).### Steps- From your lambda function assign the policy to the lambda execution role. To do so, go to the [AWS console](https://console.aws.amazon.com/console/home) β [Lambda(change to your function region)](https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/discover) β [Functions](https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/functions) β Your lambda function β Configuration tab β Permissions tab β Click the role under `Execution role` β When redirected, click Permissions tab β click `add permissions` β Click create inline policy.@@ -99,4 +99,4 @@ From the example above, the `renderMediaOnLambda()` is configured to output theThe lambda function can now move the rendered video to the other bucket when render process is completed.## See also-- [Serverless lambda setup](/docs/lambda/serverlesslambdasetup)\ No newline at end of file+- [Example setup without IAM user](/docs/lambda/example-setup-without-iam-user)\ No newline at end of filediff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 4f6012debf..29d42cb8d7 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -406,8 +406,8 @@ module.exports = {"lambda/troubleshooting/bucket-disallows-acl",],},- "lambda/lambdarolepermissions",- "lambda/serverlesslambdasetup",+ "lambda/usinglambdawithoutiamuser",+ "lambda/examplesetupwithoutiamuser","lambda/optimizing-cost","lambda/optimizing-speed","lambda/limits",diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex 466778e4fb..273732800b 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -615,6 +615,13 @@ export const articles = [compId: "articles-docs-lambda-estimateprice",crumb: "Lambda API",},+ {+ id: "examplesetupwithoutiamuser",+ title: "Example setup without IAM user",+ relativePath: "docs/lambda/examplesetupwithoutiamuser.md",+ compId: "articles-docs-lambda-examplesetupwithoutiamuser",+ crumb: "Lambda",+ },{id: "lambda/faq",title: "FAQ",@@ -832,6 +839,13 @@ export const articles = [compId: "articles-docs-lambda-upgrading",crumb: null,},+ {+ id: "usinglambdawithoutiamuser",+ title: "Using Lambda without IAM user",+ relativePath: "docs/lambda/usinglambdawithoutiamuser.md",+ compId: "articles-docs-lambda-usinglambdawithoutiamuser",+ crumb: "Lambda",+ },{id: "validatewebhooksignature",title: "validateWebhookSignature()",diff --git a/packages/docs/static/generated/articles-docs-lambda-usinglambdawithoutiamuser.png b/packages/docs/static/generated/articles-docs-lambda-usinglambdawithoutiamuser.pngnew file mode 100644index 0000000000..27a8bef647Binary files /dev/null and b/packages/docs/static/generated/articles-docs-lambda-usinglambdawithoutiamuser.png differ