-
Notifications
You must be signed in to change notification settings - Fork 4.5k
aws-lambda: function description length is not validated #20475
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-lambdaRelated to AWS LambdaRelated to AWS Lambdaeffort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p2
Description
Describe the bug
Lambda function description has length limit of 256 characters, but it is not currently validated by CDK
Expected Behavior
Lambda function description length should be validated at build time and build should fail if length is above 256 char limit
Current Behavior
Lambda function description length is not validated and issue will be caught at deployment time
Reproduction Steps
const stack = new cdk.Stack();
new lambda.Function(stack, 'MyFunction', {
code: lambda.Code.fromInline('foo'),
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
description: 'a'.repeat(257),
});Possible Solution
Validate description length:
if (props.description && !Token.isUnresolved(props.description)) {
if (props.description.length > 256) {
throw new Error(`Function description can not be longer than 256 characters but has ${props.description.length} characters.`);
}
}Additional Information/Context
No response
CDK CLI Version
2.21.1
Framework Version
No response
Node.js Version
v14.19.1
OS
Ubuntu 20
Language
Typescript
Language Version
3.8.3
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-lambdaRelated to AWS LambdaRelated to AWS Lambdaeffort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p2