🎥 Make videos programmatically with React
validation
Jonny Burgere4297788c3d2
diff --git a/packages/lambda/src/api/create-function.ts b/packages/lambda/src/api/create-function.tsindex d0bdd39b14..fb2ed8c5ad 100644--- a/packages/lambda/src/api/create-function.ts+++ b/packages/lambda/src/api/create-function.ts@@ -39,7 +39,7 @@ export const createFunction = async ({retentionInDays: number;ephemerealStorageInMb: number;architecture: LambdaArchitecture;- customRoleArn?: string;+ customRoleArn: string;}): Promise<{FunctionName: string}> => {if (createCloudWatchLogGroup) {try {@@ -67,16 +67,6 @@ export const createFunction = async ({return {FunctionName: functionName};}- if (- typeof customRoleArn !== 'undefined' &&- typeof customRoleArn !== 'string'- ) {- throw new TypeError(- 'A custom role ARN must either be "undefined" or a string, but instead got: ' +- JSON.stringify(customRoleArn)- );- }-const defaultRoleName = `arn:aws:iam::${accountId}:role/${ROLE_NAME}`;const {FunctionName} = await getLambdaClient(region).send(diff --git a/packages/lambda/src/api/deploy-function.ts b/packages/lambda/src/api/deploy-function.tsindex 88a4ebc0e8..440ec17f9f 100644--- a/packages/lambda/src/api/deploy-function.ts+++ b/packages/lambda/src/api/deploy-function.ts@@ -13,6 +13,7 @@ import {validateArchitecture,} from '../shared/validate-architecture';import {validateAwsRegion} from '../shared/validate-aws-region';+import {validateCustomRoleArn} from '../shared/validate-custom-role-arn';import {validateDiskSizeInMb} from '../shared/validate-disk-size-in-mb';import {validateMemorySize} from '../shared/validate-memory-size';import {validateCloudWatchRetentionPeriod} from '../shared/validate-retention-period';@@ -27,6 +28,7 @@ export type DeployFunctionInput = {memorySizeInMb: number;architecture: LambdaArchitecture;diskSizeInMb?: number;+ customRoleArn?: string;};export type DeployFunctionOutput = {@@ -57,6 +59,7 @@ export const deployFunction = async (validateCloudWatchRetentionPeriod(options.cloudWatchLogRetentionPeriodInDays);validateArchitecture(options.architecture);validateDiskSizeInMb(diskSizeInMb);+ validateCustomRoleArn(options.customRoleArn);const fnNameRender = [`${RENDER_FN_PREFIX}${CURRENT_VERSION}`,@@ -93,6 +96,7 @@ export const deployFunction = async (alreadyCreated: Boolean(alreadyDeployed),architecture: options.architecture,ephemerealStorageInMb: diskSizeInMb,+ customRoleArn: options.customRoleArn as string,});if (!created.FunctionName) {diff --git a/packages/lambda/src/cli/commands/functions/deploy.ts b/packages/lambda/src/cli/commands/functions/deploy.tsindex fd872749d7..c7168f01fd 100644--- a/packages/lambda/src/cli/commands/functions/deploy.ts+++ b/packages/lambda/src/cli/commands/functions/deploy.ts@@ -10,6 +10,7 @@ import {DEFAULT_TIMEOUT,} from '../../../shared/constants';import {validateArchitecture} from '../../../shared/validate-architecture';+import {validateCustomRoleArn} from '../../../shared/validate-custom-role-arn';import {validateDiskSizeInMb} from '../../../shared/validate-disk-size-in-mb';import {validateMemorySize} from '../../../shared/validate-memory-size';import {validateTimeout} from '../../../shared/validate-timeout';@@ -24,6 +25,7 @@ export const functionsDeploySubcommand = async () => {const memorySizeInMb = parsedLambdaCli.memory ?? DEFAULT_MEMORY_SIZE;const diskSizeInMb = parsedLambdaCli.disk ?? DEFAULT_EPHEMERAL_STORAGE_IN_MB;const architecture = parsedLambdaCli.architecture ?? DEFAULT_ARCHITECTURE;+ const customRoleArn = parsedLambdaCli['custom-role-arn'] ?? undefined;const createCloudWatchLogGroup = !parsedLambdaCli['disable-cloudwatch'];const cloudWatchLogRetentionPeriodInDays =parsedLambdaCli['retention-period'] ?? DEFAULT_CLOUDWATCH_RETENTION_PERIOD;@@ -32,6 +34,7 @@ export const functionsDeploySubcommand = async () => {validateTimeout(timeoutInSeconds);validateArchitecture(architecture);validateDiskSizeInMb(diskSizeInMb);+ validateCustomRoleArn(customRoleArn);if (!CliInternals.quietFlagProvided()) {Log.info(CliInternals.chalk.gray(@@ -61,6 +64,7 @@ CloudWatch Retention Period = ${cloudWatchLogRetentionPeriodInDays} dayscloudWatchLogRetentionPeriodInDays,architecture,diskSizeInMb,+ customRoleArn,});if (CliInternals.quietFlagProvided()) {Log.info(functionName);diff --git a/packages/lambda/src/shared/validate-custom-role-arn.ts b/packages/lambda/src/shared/validate-custom-role-arn.tsnew file mode 100644index 0000000000..917a76da3d--- /dev/null+++ b/packages/lambda/src/shared/validate-custom-role-arn.ts@@ -0,0 +1,11 @@+export const validateCustomRoleArn = (customRoleArn: unknown) => {+ if (+ typeof customRoleArn !== 'undefined' &&+ typeof customRoleArn !== 'string'+ ) {+ throw new TypeError(+ 'A custom role ARN must either be "undefined" or a string, but instead got: ' ++ JSON.stringify(customRoleArn)+ );+ }+};