Skip to content

🎥 Make videos programmatically with React

Resolve upstream conflicts

Evan Cloutier99dd5b3be60b
diff --cc .gitignore
index 9049cce4aa,3544caafd8..5306b0eedf
--- a/.gitignore
+++ b/.gitignore
@@@ -4,5 -4,5 +4,6 @@@ tsconfig.tsbuildinf
.DS_Store
coverage
packages/example/.env
+*/**/.env
+ .cache
+ packages/example/out
diff --cc packages/example/out.mp4
index 3319e445f0,5260cb0332..0000000000
deleted file mode 100644,100644
Binary files differ
diff --cc packages/lambda/src/api/create-function.ts
index 83212989fa,a53e77c7d0..12265b5dc1
--- a/packages/lambda/src/api/create-function.ts
+++ b/packages/lambda/src/api/create-function.ts
@@@ -1,53 -1,28 +1,55 @@@
+import {
+ CreateLogGroupCommand,
+ PutRetentionPolicyCommand,
+} from '@aws-sdk/client-cloudwatch-logs';
- import {CreateFunctionCommand} from '@aws-sdk/client-lambda';
- import {Log} from '@remotion/cli/dist/log';
+ import {
+ CreateFunctionCommand,
+ PutFunctionEventInvokeConfigCommand,
+ } from '@aws-sdk/client-lambda';
import {readFileSync} from 'fs';
import {AwsRegion} from '..';
+ import {Log} from '../cli/log';
-import {getLambdaClient} from '../shared/aws-clients';
+import {
+ DEFAULT_CLOUDWATCH_RETENTION_PERIOD,
+ LOG_GROUP_PREFIX,
+} from '../defaults';
+import {getCloudWatchLogsClient, getLambdaClient} from '../shared/aws-clients';
+ import {hostedLayers} from '../shared/hosted-layers';
export const createFunction = async ({
+ createCloudWatchLogGroup = false,
region,
zipFile,
functionName,
accountId,
memorySizeInMb,
timeoutInSeconds,
- layerArn,
}: {
+ createCloudWatchLogGroup?: boolean;
region: AwsRegion;
zipFile: string;
functionName: string;
accountId: string;
memorySizeInMb: number;
timeoutInSeconds: number;
- layerArn: string;
}) => {
+ if (createCloudWatchLogGroup) {
+ Log.info(`Creating CloudWatch Log Group...`);
+
+ await getCloudWatchLogsClient(region).send(
+ new CreateLogGroupCommand({
+ logGroupName: `${LOG_GROUP_PREFIX}${functionName}`,
+ })
+ );
+
+ await getCloudWatchLogsClient(region).send(
+ new PutRetentionPolicyCommand({
+ logGroupName: `${LOG_GROUP_PREFIX}${functionName}`,
+ retentionInDays: DEFAULT_CLOUDWATCH_RETENTION_PERIOD,
+ })
+ );
+ }
+
const {FunctionName} = await getLambdaClient(region).send(
new CreateFunctionCommand({
Code: {
diff --cc packages/lambda/src/api/deploy-function.ts
index d2d826f64e,c3e0f65beb..1a99ea2282
--- a/packages/lambda/src/api/deploy-function.ts
+++ b/packages/lambda/src/api/deploy-function.ts
@@@ -11,17 -11,13 +11,15 @@@ import {createFunction} from './create-
/**
* @description Creates an AWS Lambda function in your account that will be able to render a video in the cloud.
* @link https://remotion.dev/docs/lambda/deployfunction
+ * @param options.createCloudWatchLogGroup Whether you'd like to create a CloudWatch Log Group to store the logs for this function.
* @param options.region The region you want to deploy your function to.
- * @param options.layerArn The resource identifier of the Lambda layer. See documentation for this function on how to retrieve it.
* @param options.timeoutInSeconds After how many seconds the lambda function should be killed if it does not end itself.
* @param options.memorySizeInMb How much memory should be allocated to the Lambda function.
* @returns An object that contains the `functionName` property
*/
export const deployFunction = async (options: {
+ createCloudWatchLogGroup?: boolean;
region: AwsRegion;
- layerArn: string;
timeoutInSeconds: number;
memorySizeInMb: number;
}) => {
@@@ -30,15 -26,11 +28,12 @@@
validateAwsRegion(options.region);
const fnNameRender = RENDER_FN_PREFIX + randomHash();
- const [renderOut, accountId] = await Promise.all([
- bundleLambda(),
- getAccountId({region: options.region}),
- ]);
+ const accountId = await getAccountId({region: options.region});
const created = await createFunction({
+ createCloudWatchLogGroup: options.createCloudWatchLogGroup,
region: options.region,
- zipFile: renderOut,
+ zipFile: FUNCTION_ZIP,
functionName: fnNameRender,
accountId,
memorySizeInMb: options.memorySizeInMb,
diff --cc packages/lambda/src/api/iam-validation/required-permissions.ts
index 136cc85bbb,1764d98c3b..0b92de0d9e
--- a/packages/lambda/src/api/iam-validation/required-permissions.ts
+++ b/packages/lambda/src/api/iam-validation/required-permissions.ts
@@@ -1,9 -1,5 +1,5 @@@
-import {iam, lambda, s3} from 'aws-policies';
+import {iam, lambda, logs, s3} from 'aws-policies';
- import {
- BINARIES_BUCKET_PREFIX,
- REMOTION_BUCKET_PREFIX,
- RENDER_FN_PREFIX,
- } from '../../shared/constants';
+ import {REMOTION_BUCKET_PREFIX, RENDER_FN_PREFIX} from '../../shared/constants';
// TODO: Update docs before release
export const requiredPermissions: {
@@@ -61,24 -53,12 +53,21 @@@
resource: [`arn:aws:lambda:*:*:function:${RENDER_FN_PREFIX}*`],
},
{
- actions: [lambda.PublishLayerVersion],
- resource: ['arn:aws:lambda:*:*:layer:remotion-binaries'],
- },
- {
- actions: [lambda.DeleteLayerVersion, lambda.GetLayerVersion],
- resource: ['arn:aws:lambda:*:*:layer:*:*'],
+ actions: [lambda.GetLayerVersion],
+ // TODO: Tighten up
+ resource: [`*`],
},
{
- actions: [lambda.ListLayers, lambda.ListFunctions],
+ actions: [lambda.ListFunctions],
resource: ['*'],
},
+ {
+ actions: [
+ logs.CreateLogGroup,
+ logs.CreateLogStream,
+ logs.PutLogEvents,
+ logs.PutRetentionPolicy,
+ ],
+ resource: ['arn:aws:logs:*:*:log-group:*'],
+ },
];
diff --cc packages/lambda/src/cli/commands/functions/deploy.ts
index 5e2b8ab3b9,4383791aaf..d791bcb2f6
--- a/packages/lambda/src/cli/commands/functions/deploy.ts
+++ b/packages/lambda/src/cli/commands/functions/deploy.ts
@@@ -28,16 -26,11 +27,12 @@@ export const functionsDeploySubcommand
)
);
const output = CliInternals.createOverwriteableCliOutput();
- output.update('Ensuring Lambda binaries...');
- // TODO: Output can be more finegrained
- const {layerArn} = await ensureLambdaBinaries(getAwsRegion());
- output.update('Bundling lambda and deploying...');
+ output.update('Deploying Lambda...');
const {functionName} = await deployFunction({
+ createCloudWatchLogGroup,
region,
timeoutInSeconds,
- layerArn,
memorySizeInMb,
});
- output.update(`Deployed to ${functionName}\n`);
+ output.update(`Deployed as ${functionName}\n`);
};