I've noticed that while there's a CDK construct for AWS Lambda functions in TypeScript, the corresponding Python construct is still in alpha. What's the reasoning behind this, especially with the ongoing development in the Python ecosystem? As someone who's relatively new to Python (only started using it in the last couple of years), but has been a developer for much longer, I'm curious about the insights others might have. I'm currently rewriting a project and considering whether to deploy my API (written in Python) as a Lambda instead of on ECS Fargate. This limitation in the CDK caught me off guard while coding, and I'd like to understand it better.
2 Answers
You can definitely use the general Function construct and handle the packaging yourself during deployment. I’d recommend avoiding alpha code for production use. It’s not hard to build your own deployment package!
There are a couple of reasons for this situation. First, CDK is primarily written in TypeScript, so naturally, developers tend to stick with that language. Plus, bundling JavaScript into a single file is generally straightforward compared to creating a zip file for a Python Lambda. The Python construct has been in alpha for a while but seems to work fine for most cases. Many developers just prefer to manage their Lambda zip files separately outside of CDK.

Fun fact: CDK uses jsii, a polyglot library, to generate non-JS CDK libraries from the TypeScript code instead of maintaining separate versions!