🎥 Make videos programmatically with React
docs
Jonny Burgerdef125525dfc
diff --git a/packages/docs/docs/lambda/cli.md b/packages/docs/docs/lambda/cli.mdindex c262368f6a..276a8578f3 100644--- a/packages/docs/docs/lambda/cli.md+++ b/packages/docs/docs/lambda/cli.md@@ -12,6 +12,7 @@ slug: /lambda/cli- [render](/docs/lambda/cli/render)- [still](/docs/lambda/cli/still)- [policies](/docs/lambda/cli/policies)+- [quotas](/docs/lambda/cli/quotas)## Global optionsdiff --git a/packages/docs/docs/lambda/cli/quotas.md b/packages/docs/docs/lambda/cli/quotas.mdnew file mode 100644index 0000000000..3062c5b09a--- /dev/null+++ b/packages/docs/docs/lambda/cli/quotas.md@@ -0,0 +1,61 @@+---+id: quotas+sidebar_label: quotas+title: "npx remotion lambda quotas"+slug: /lambda/cli/quotas+---++Displays the AWS Lambda concurrency and burst limits currently being applied to your account and region. You can use the `increase` command to send a request to AWS asking them to increase their quotas.++- [`quotas`](#quotas)+- [`quotas increase`](#quotas-increase)++## `quotas`++Print the current limits being applied to your AWS account and region.++```+npx remotion lambda quotas+```++<details>+<summary>Show example output+</summary>+<pre>+Region = us-east-1++Concurrency limit: 1000 - Increase recommended!+A request to increase it to 5000 is pending:+https://us-east-1.console.aws.amazon.com/support/home#/case/?displayId=9742781451+The maximum amount of Lambda functions which can concurrently execute.+Run `npx remotion lambda quotas increase` to ask AWS to increase your limit.++Burst concurrency: 3000, but only 1000 effective because of concurrency limit+The maximum amount of Lambda functions that can spawn in a short amount of time++</pre>+</details>++### `--region`++For which region the quotas should be printed.++## `quotas increase`++Creates an AWS support request to increase the concurrency limit on your account as well as potential quota increase requests that might exist on your account.++```+npx remotion lambda quotas increase+```++### `--region`++For which region the quotas should be increased.++### `--yes`++Skips asking for confirmation.++## See also++- [Setup guide](/docs/lambda/setup)diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 7af252ab48..09859ba060 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -59,6 +59,7 @@ module.exports = {"lambda/cli/still","lambda/cli/policies","lambda/cli/regions",+ "lambda/cli/quotas",],},"lambda/setup",diff --git a/packages/lambda/src/api/iam-validation/user-permissions.ts b/packages/lambda/src/api/iam-validation/user-permissions.tsindex 10a269b2fb..ef65b21871 100644--- a/packages/lambda/src/api/iam-validation/user-permissions.ts+++ b/packages/lambda/src/api/iam-validation/user-permissions.ts@@ -17,6 +17,7 @@ export const requiredPermissions: {servicequotas.GetServiceQuota,servicequotas.GetAWSDefaultServiceQuota,servicequotas.RequestServiceQuotaIncrease,+ servicequotas.ListRequestedServiceQuotaChangeHistoryByQuota,],resource: ['*'],},diff --git a/packages/lambda/src/cli/commands/quotas/increase.ts b/packages/lambda/src/cli/commands/quotas/increase.tsnew file mode 100644index 0000000000..be84714c39--- /dev/null+++ b/packages/lambda/src/cli/commands/quotas/increase.ts@@ -0,0 +1,84 @@+import {+ GetAWSDefaultServiceQuotaCommand,+ GetServiceQuotaCommand,+ ListRequestedServiceQuotaChangeHistoryByQuotaCommand,+ RequestServiceQuotaIncreaseCommand,+} from '@aws-sdk/client-service-quotas';+import {Log} from '@remotion/cli/dist/log';+import {exit} from 'process';+import {QUOTAS_COMMAND} from '.';+import {BINARY_NAME, LAMBDA_CONCURRENCY_LIMIT_QUOTA} from '../../../defaults';+import {getServiceQuotasClient} from '../../../shared/aws-clients';+import {getAwsRegion} from '../../get-aws-region';+import {confirmCli} from '../../helpers/confirm';+import {quit} from '../../helpers/quit';++export const INCREASE_SUBCOMMAND = 'increase';++export const quotasIncreaseCommand = async () => {+ const region = getAwsRegion();++ const [concurrencyLimit, defaultConcurrencyLimit, changes] =+ await Promise.all([+ getServiceQuotasClient(region).send(+ new GetServiceQuotaCommand({+ QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,+ ServiceCode: 'lambda',+ })+ ),+ getServiceQuotasClient(region).send(+ new GetAWSDefaultServiceQuotaCommand({+ QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,+ ServiceCode: 'lambda',+ })+ ),+ getServiceQuotasClient(region).send(+ new ListRequestedServiceQuotaChangeHistoryByQuotaCommand({+ QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,+ ServiceCode: 'lambda',+ })+ ),+ ]);++ const openCase = changes.RequestedQuotas?.find(+ (r) => r.Status === 'CASE_OPENED'+ );+ if (openCase) {+ Log.warn(+ `A request to increase it to ${openCase.DesiredValue} is already pending:`+ );+ Log.warn(+ `https://${region}.console.aws.amazon.com/support/home#/case/?displayId=${openCase.CaseId}`+ );+ exit(1);+ }++ const concurrencyCurrent = concurrencyLimit.Quota?.Value as number;+ const defaultConcurrency = defaultConcurrencyLimit.Quota?.Value as number;+ const increaseRecommended = concurrencyCurrent <= defaultConcurrency;+ if (!increaseRecommended) {+ Log.info(+ `Current limit of ${concurrencyCurrent} is already increased over the default (${defaultConcurrency}). Increase it further via the AWS console.`+ );+ quit(1);+ }++ const newLimit = Math.floor(concurrencyCurrent / 5000) * 5000 + 5000;+ Log.info(+ `Sending request to AWS to increase concurrency limit from ${concurrencyCurrent} to ${newLimit}.`+ );+ await confirmCli({+ allowForceFlag: true,+ delMessage: 'Send? (Y/n)',+ });+ await getServiceQuotasClient(region).send(+ new RequestServiceQuotaIncreaseCommand({+ QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,+ DesiredValue: newLimit,+ ServiceCode: 'lambda',+ })+ );+ Log.info(+ `Requested increase successfully. Run "${BINARY_NAME} ${QUOTAS_COMMAND}" to check whether your request was approved.`+ );+};diff --git a/packages/lambda/src/cli/commands/quotas/index.ts b/packages/lambda/src/cli/commands/quotas/index.tsindex 6f8c9d5e38..b0d40ea649 100644--- a/packages/lambda/src/cli/commands/quotas/index.ts+++ b/packages/lambda/src/cli/commands/quotas/index.ts@@ -1,81 +1,29 @@-import {- GetAWSDefaultServiceQuotaCommand,- GetServiceQuotaCommand,-} from '@aws-sdk/client-service-quotas';import {CliInternals} from '@remotion/cli';import {Log} from '@remotion/cli/dist/log';-import {- LAMBDA_BURST_LIMIT_QUOTA,- LAMBDA_CONCURRENCY_LIMIT_QUOTA,-} from '../../../defaults';-import {getServiceQuotasClient} from '../../../shared/aws-clients';-import {getAwsRegion} from '../../get-aws-region';-+import {BINARY_NAME} from '../../../defaults';+import {INCREASE_SUBCOMMAND, quotasIncreaseCommand} from './increase';+import {quotasListCommand} from './list';export const QUOTAS_COMMAND = 'quotas';-export const quotasCommand = async () => {- const region = getAwsRegion();- Log.info(CliInternals.chalk.gray(`Region = ${region}`));+const printHelp = () => {+ Log.info('Available commands:');Log.info();- const [concurrencyLimit, defaultConcurrencyLimit, burstLimit] =- await Promise.all([- getServiceQuotasClient(region).send(- new GetServiceQuotaCommand({- QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,- ServiceCode: 'lambda',- })- ),- getServiceQuotasClient(region).send(- new GetAWSDefaultServiceQuotaCommand({- QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,- ServiceCode: 'lambda',- })- ),- getServiceQuotasClient(region).send(- new GetAWSDefaultServiceQuotaCommand({- QuotaCode: LAMBDA_BURST_LIMIT_QUOTA,- ServiceCode: 'lambda',- })- ),- ]);-- const concurrencyCurrent = concurrencyLimit.Quota?.Value as number;- const defaultConcurrency = defaultConcurrencyLimit.Quota?.Value as number;- const burstDefault = burstLimit.Quota?.Value as number;-- const increaseRecommended = concurrencyCurrent <= defaultConcurrency;- const effectiveBurstConcurrency = Math.min(burstDefault, defaultConcurrency);+ Log.info(`npx ${BINARY_NAME} ${QUOTAS_COMMAND}`);+ Log.info(CliInternals.chalk.gray('List relevant AWS Lambda quotas.'));+ Log.info();+ Log.info(`npx ${BINARY_NAME} ${QUOTAS_COMMAND} ${INCREASE_SUBCOMMAND}`);+ Log.info(CliInternals.chalk.gray('Increase Lambda quotas.'));+};- if (increaseRecommended) {- Log.info(- `Concurrency limit: ${concurrencyCurrent} - ${- increaseRecommended- ? CliInternals.chalk.greenBright('Increase recommended!')- : ''- }`- );- } else {- Log.info(`Concurrency limit: ${concurrencyCurrent}`);+export const quotasCommand = (args: string[]) => {+ if (args.filter(Boolean).length === 0) {+ return quotasListCommand();}- Log.info(- CliInternals.chalk.gray(- 'The maximum amount of Lambda functions which can concurrently execute'- )- );- Log.info();-- if (effectiveBurstConcurrency === burstDefault) {- Log.info(`Burst concurrency: ${burstDefault}`);- } else {- Log.info(- `Burst concurrency: ${burstDefault}, but only ${effectiveBurstConcurrency} effective because of concurrency limit`- );+ if (args[0] === INCREASE_SUBCOMMAND) {+ return quotasIncreaseCommand();}- Log.info(- CliInternals.chalk.gray(- 'The maximum amount of Lambda functions that can spawn in a short amount of time'- )- );+ Log.error('Subcommand ' + args[0] + ' not found.');+ printHelp();};diff --git a/packages/lambda/src/cli/commands/quotas/list.ts b/packages/lambda/src/cli/commands/quotas/list.tsnew file mode 100644index 0000000000..30ffff52a5--- /dev/null+++ b/packages/lambda/src/cli/commands/quotas/list.ts@@ -0,0 +1,107 @@+import {+ GetAWSDefaultServiceQuotaCommand,+ GetServiceQuotaCommand,+ ListRequestedServiceQuotaChangeHistoryByQuotaCommand,+} from '@aws-sdk/client-service-quotas';+import {CliInternals} from '@remotion/cli';+import {QUOTAS_COMMAND} from '.';+import {+ BINARY_NAME,+ LAMBDA_BURST_LIMIT_QUOTA,+ LAMBDA_CONCURRENCY_LIMIT_QUOTA,+} from '../../../defaults';+import {getServiceQuotasClient} from '../../../shared/aws-clients';+import {getAwsRegion} from '../../get-aws-region';+import {Log} from '../../log';+import {INCREASE_SUBCOMMAND} from './increase';++export const quotasListCommand = async () => {+ const region = getAwsRegion();+ Log.info(CliInternals.chalk.gray(`Region = ${region}`));+ Log.info();+ const [concurrencyLimit, defaultConcurrencyLimit, burstLimit, changes] =+ await Promise.all([+ getServiceQuotasClient(region).send(+ new GetServiceQuotaCommand({+ QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,+ ServiceCode: 'lambda',+ })+ ),+ getServiceQuotasClient(region).send(+ new GetAWSDefaultServiceQuotaCommand({+ QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,+ ServiceCode: 'lambda',+ })+ ),+ getServiceQuotasClient(region).send(+ new GetAWSDefaultServiceQuotaCommand({+ QuotaCode: LAMBDA_BURST_LIMIT_QUOTA,+ ServiceCode: 'lambda',+ })+ ),+ getServiceQuotasClient(region).send(+ new ListRequestedServiceQuotaChangeHistoryByQuotaCommand({+ QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,+ ServiceCode: 'lambda',+ })+ ),+ ]);++ const openCase = changes.RequestedQuotas?.find(+ (r) => r.Status === 'CASE_OPENED'+ );++ const concurrencyCurrent = concurrencyLimit.Quota?.Value as number;+ const defaultConcurrency = defaultConcurrencyLimit.Quota?.Value as number;+ const burstDefault = burstLimit.Quota?.Value as number;++ const increaseRecommended = concurrencyCurrent <= defaultConcurrency;+ const effectiveBurstConcurrency = Math.min(burstDefault, defaultConcurrency);++ if (increaseRecommended) {+ Log.info(+ `Concurrency limit: ${concurrencyCurrent} - ${+ increaseRecommended+ ? CliInternals.chalk.greenBright('Increase recommended!')+ : ''+ }`+ );+ } else {+ Log.info(`Concurrency limit: ${concurrencyCurrent}`);+ }++ if (openCase) {+ Log.warn(+ `A request to increase it to ${openCase.DesiredValue} is pending:`+ );+ Log.warn(+ `https://${region}.console.aws.amazon.com/support/home#/case/?displayId=${openCase.CaseId}`+ );+ }++ Log.info(+ CliInternals.chalk.gray(+ 'The maximum amount of Lambda functions which can concurrently execute.'+ )+ );+ Log.info(+ CliInternals.chalk.gray(+ `Run \`npx ${BINARY_NAME} ${QUOTAS_COMMAND} ${INCREASE_SUBCOMMAND}\` to ask AWS to increase your limit.`+ )+ );+ Log.info();++ if (effectiveBurstConcurrency === burstDefault) {+ Log.info(`Burst concurrency: ${burstDefault}`);+ } else {+ Log.info(+ `Burst concurrency: ${burstDefault}, but only ${effectiveBurstConcurrency} effective because of concurrency limit`+ );+ }++ Log.info(+ CliInternals.chalk.gray(+ 'The maximum amount of Lambda functions that can spawn in a short amount of time'+ )+ );+};diff --git a/packages/lambda/src/cli/help.ts b/packages/lambda/src/cli/help.tsindex 1899bb76a9..b434f92484 100644--- a/packages/lambda/src/cli/help.ts+++ b/packages/lambda/src/cli/help.ts@@ -2,6 +2,7 @@ import {CliInternals} from '@remotion/cli';import {BINARY_NAME} from '../shared/constants';import {FUNCTIONS_COMMAND} from './commands/functions';import {POLICIES_COMMAND} from './commands/policies/policies';+import {QUOTAS_COMMAND} from './commands/quotas';import {REGIONS_COMMAND} from './commands/regions';import {RENDER_COMMAND} from './commands/render/render';import {SITES_COMMAND} from './commands/sites';@@ -41,4 +42,10 @@ export const printHelp = () => {Log.info();Log.info(`${BINARY_NAME} ${REGIONS_COMMAND}`);Log.info(CliInternals.chalk.gray('Show the list of AWS regions supported.'));++ Log.info();+ Log.info(`${BINARY_NAME} ${QUOTAS_COMMAND}`);+ Log.info(+ CliInternals.chalk.gray('Shows AWS quotas and allows to increase them.')+ );};diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.tsindex 359245c5e3..0852debdc0 100644--- a/packages/lambda/src/cli/index.ts+++ b/packages/lambda/src/cli/index.ts@@ -58,7 +58,7 @@ const matchCommand = (args: string[]) => {}if (args[0] === QUOTAS_COMMAND) {- return quotasCommand();+ return quotasCommand(args.slice(1));}if (args[0] === POLICIES_COMMAND) {