PythonFunction construct support using container images
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 71
Description
### Describe the feature
We use the [`PythonFunction`](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-lambda-python-alpha.PythonFunction.html) construct which has been great so far, especially with its automatic bundling and deployments in CDK pipelines within CodePipeline. Integrating both our Lambda function and Lambda layers into our CI/CD process has been a great experience so far.
However, we have also ran into this issue after adding a few common dependencies to our `Layer` (just `pandas`, `requests`, and `openpyxl`):
```
Function code combined with layers exceeds the maximum allowed size of 262144000 bytes. The actual size is
276132097 bytes.
```
I believe the recommended workaround for this at this point is to use container images for all Lambda functions that exceed this limit. I believe the CDK should to adopt this recommendation by allowing that we switch to a container-based deployment if the package exceeds Lambda's size limits.
We currently own around 10 lambda functions, all of which use the `PythonFunction` construct. I don't want to rearchitect our entire CI/CD process and migrate off such a great tool just to address this concern. I would expect that this great customer experience would be something that the CDK would be able to continue to support now that there is a recommended solution provided by Lambda.
### Use Case
To continue to use the PythonFunction construct within the CDK and automate asset deployments in CodePipeline, we believe it would be ideal to have this supported in the construct itself.
### Proposed Solution
Either detect the unzipped size before and automatically switch to using container deployments or just allow for it to be configurable as a flag for each `PythonFunction`.
### Other Information
_No response_
### Acknowledgements
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2
### Environment details (OS name and version, etc.)
MacOS Ventura 13.4
Contributor guide
Research direction
Start by examining the PythonFunction construct's bundling and deployment entry points, along with its Lambda asset deployment behavior. Decide whether configurable container-image support or automatic switching is appropriate; done means oversized PythonFunction deployments can use container images while continuing to work with automated deployments in CodePipeline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100