CDK Construct for Python Lambda Functions using [uv](https://docs.astral.sh/uv/)
npm install uv-python-lambdaCDK Construct for Python Lambda Functions using uv
- ⚡️ Package and deploy Lambda Functions faster with uv's speed
- 📦 Support workspaces in a monorepo with uv workspaces
uv-python-lambda is based on aws-lambda-python-alpha with some differences:
- It only supports uv for packaging - there is no Poetry or pip support
- It supports workspaces so you can build multiple Lambda functions from different uv workspaces and have their dependencies included correctly. This is useful for, but not limited to, monorepos.
See API.md
``python
from uv_python_lambda import PythonFunction
from constructs import Construct
class CdkStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
fn = PythonFunction(
self,
"fn",
root_dir=str(root_path),
index="fetcher_lambda.py",
workspace_package="fetcher", # Use a workspace package as the top-level Lambda entry point.
handler="handle_event",
bundling={
"asset_excludes": [
".venv/",
"node_modules/",
"cdk/",
".git/",
".idea/",
"dist/",
]
},
timeout=Duration.seconds(30),
)
``