aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.57k stars 3.87k forks source link

aws_cdk.aws_lambda.Code: from_inline method code size limit incorrect #30761

Open ayankowsky opened 3 months ago

ayankowsky commented 3 months ago

Describe the issue

The CDK documentation for from_inline states the code parameter has a size limit of 4KiB. However, this limit is actually 4MB according to the CloudFormation documentation for ZipFile size, which is what from_inline will synthesize to.

I tested this by providing a string that was larger than 4KB, and CDK successfully synthesized a template without error.

Links

https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_lambda/Code.html#aws_cdk.aws_lambda.Code.from_inline https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html

khushail commented 3 months ago

Thanks @ayankowsky for reporting this. Indeed, its mentioned in clodufromation as

`` (Node.js and Python) The source code of your Lambda function. If you include your function source inline with this parameter, AWS CloudFormation places it in a file named index and zips it to create a deployment package. This zip file cannot exceed 4MB. For the Handler property, the first part of the handler identifier must be index. For example, index.handler..