Skip to content

🎥 Make videos programmatically with React

quota increase: allow --force, show console url, better error message for when subaccount

Jonny Burger1c7f52d3ec32
diff --git a/packages/docs/docs/lambda/cli/quotas.md b/packages/docs/docs/lambda/cli/quotas.md
index ddcf7ab238..88f8d00cf6 100644
--- a/packages/docs/docs/lambda/cli/quotas.md
+++ b/packages/docs/docs/lambda/cli/quotas.md
@@ -62,6 +62,10 @@ For which region the quotas should be increased.
Skips asking for confirmation.
+### `--force`
+
+Asks for an increase even if it is the second one. Without a message you specify, it is more unlikely you will get approved, prefer using console for further increases.
+
## See also
- [Setup guide](/docs/lambda/setup)
diff --git a/packages/lambda/src/cli/commands/quotas/increase.ts b/packages/lambda/src/cli/commands/quotas/increase.ts
index a63e3db3f8..536be27191 100644
--- a/packages/lambda/src/cli/commands/quotas/increase.ts
+++ b/packages/lambda/src/cli/commands/quotas/increase.ts
@@ -4,17 +4,29 @@ import {
ListRequestedServiceQuotaChangeHistoryByQuotaCommand,
RequestServiceQuotaIncreaseCommand,
} from '@aws-sdk/client-service-quotas';
-import {CliInternals} from '@remotion/cli';
import {exit} from 'process';
import {QUOTAS_COMMAND} from '.';
+import type {AwsRegion} from '../../../client';
import {BINARY_NAME, LAMBDA_CONCURRENCY_LIMIT_QUOTA} from '../../../defaults';
import {getServiceQuotasClient} from '../../../shared/aws-clients';
+import {forceFlagProvided} from '../../args';
import {getAwsRegion} from '../../get-aws-region';
import {confirmCli} from '../../helpers/confirm';
import {quit} from '../../helpers/quit';
+import {Log} from '../../log';
export const INCREASE_SUBCOMMAND = 'increase';
+const makeQuotaUrl = ({
+ region,
+ quotaId,
+}: {
+ region: AwsRegion;
+ quotaId: string;
+}) => {
+ return `https://${region}.console.aws.amazon.com/servicequotas/home/services/lambda/quotas/${quotaId}`;
+};
+
export const quotasIncreaseCommand = async () => {
const region = getAwsRegion();
@@ -44,10 +56,10 @@ export const quotasIncreaseCommand = async () => {
(r) => r.Status === 'CASE_OPENED'
);
if (openCase) {
- CliInternals.Log.warn(
+ Log.warn(
`A request to increase it to ${openCase.DesiredValue} is already pending:`
);
- CliInternals.Log.warn(
+ Log.warn(
`https://${region}.console.aws.amazon.com/support/home#/case/?displayId=${openCase.CaseId}`
);
exit(1);
@@ -56,29 +68,52 @@ export const quotasIncreaseCommand = async () => {
const concurrencyCurrent = concurrencyLimit.Quota?.Value as number;
const defaultConcurrency = defaultConcurrencyLimit.Quota?.Value as number;
const increaseRecommended = concurrencyCurrent <= defaultConcurrency;
- if (!increaseRecommended) {
- CliInternals.Log.info(
- `Current limit of ${concurrencyCurrent} is already increased over the default (${defaultConcurrency}). Increase it further via the AWS console.`
+ if (!increaseRecommended && !forceFlagProvided) {
+ Log.error(
+ `Current limit of ${concurrencyCurrent} is already increased over the default (${defaultConcurrency}).`
);
+ Log.info('You can force the increase with the --force flag.');
+ Log.info(
+ 'You are more likely to get an increase if you attach a reason. Go so by going to the AWS console:'
+ );
+ Log.info(makeQuotaUrl({quotaId: LAMBDA_CONCURRENCY_LIMIT_QUOTA, region}));
quit(1);
}
const newLimit = Math.floor(concurrencyCurrent / 5000) * 5000 + 5000;
- CliInternals.Log.info(
+ 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',
- })
- );
- CliInternals.Log.info(
+ try {
+ await getServiceQuotasClient(region).send(
+ new RequestServiceQuotaIncreaseCommand({
+ QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,
+ DesiredValue: newLimit,
+ ServiceCode: 'lambda',
+ })
+ );
+ } catch (err) {
+ if ((err as Error).name === 'DependencyAccessDeniedException') {
+ Log.error(
+ 'Could not request increase because this is a sub-account of another AWS account.'
+ );
+ Log.error(
+ `Please go to ${makeQuotaUrl({
+ quotaId: LAMBDA_CONCURRENCY_LIMIT_QUOTA,
+ region,
+ })} to request the increase via the AWS console.`
+ );
+ return;
+ }
+
+ throw err;
+ }
+
+ Log.info(
`Requested increase successfully. Run "${BINARY_NAME} ${QUOTAS_COMMAND}" to check whether your request was approved.`
);
};