Skip to content

Commit 5a47d21

Browse files
authored
add error mapping for lambda exceeding max size (#2295)
* add error mapping for lambda exceeding max size * update resolution message
1 parent daaedb6 commit 5a47d21

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

.changeset/new-mails-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/backend-deployer': patch
3+
---
4+
5+
add error mapping for lambda exceeding max size

packages/backend-deployer/src/cdk_error_mapper.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,18 @@ npm error enoent`,
621621
errorName: 'CloudFormationDeletionError',
622622
expectedDownstreamErrorMessage: undefined,
623623
},
624+
{
625+
errorMessage: `Error: some-stack failed: InvalidParameterValueException: Unzipped size must be smaller than 262144000 bytes`,
626+
expectedTopLevelErrorMessage: 'Maximum Lambda size exceeded',
627+
errorName: 'LambdaMaxSizeExceededError',
628+
expectedDownstreamErrorMessage: undefined,
629+
},
630+
{
631+
errorMessage: `Error: some-stack failed: InvalidParameterValueException: Function code combined with layers exceeds the maximum allowed size of 262144000 bytes. The actual size is 306703523 bytes.`,
632+
expectedTopLevelErrorMessage: 'Maximum Lambda size exceeded',
633+
errorName: 'LambdaMaxSizeExceededError',
634+
expectedDownstreamErrorMessage: undefined,
635+
},
624636
];
625637

626638
void describe('invokeCDKCommand', { concurrency: 1 }, () => {

packages/backend-deployer/src/cdk_error_mapper.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ export class CdkErrorMapper {
220220
errorName: 'MultipleSandboxInstancesError',
221221
classification: 'ERROR',
222222
},
223+
{
224+
errorRegex:
225+
/InvalidParameterValueException:(.*) (size must be smaller than|exceeds the maximum allowed size of) (?<maxSize>\d+) bytes/,
226+
humanReadableErrorMessage: 'Maximum Lambda size exceeded',
227+
resolutionMessage:
228+
'Make sure your Lambda bundled packages with layers and dependencies is smaller than {maxSize} bytes unzipped.',
229+
errorName: 'LambdaMaxSizeExceededError',
230+
classification: 'ERROR',
231+
},
223232
{
224233
errorRegex:
225234
/User:(.*) is not authorized to perform: lambda:GetLayerVersion on resource:(.*) because no resource-based policy allows the lambda:GetLayerVersion action/,
@@ -493,4 +502,5 @@ export type CDKDeploymentError =
493502
| 'InvalidPackageJsonError'
494503
| 'SecretNotSetError'
495504
| 'SyntaxError'
496-
| 'GetLambdaLayerVersionError';
505+
| 'GetLambdaLayerVersionError'
506+
| 'LambdaMaxSizeExceededError';

0 commit comments

Comments
 (0)