aws-lambda-python-alpha: BundlingOptions exclude all assets and explicit include
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
Add a mode to BundlingOptions where it will import only a explicit written list of files/directories as opposed to the current pattern using asset_excludes
### Use Case
I propose adding a mode to the BundlingOptions in the CDK that allows for specifying assets to include explicitly, rather than excluding assets. This inclusion mode will simplify configurations where only a few files or directories need to be bundled, enhancing clarity and reducing configuration complexity.
This feature will benefit AWS Lambda functions by potentially reducing deployment package size, thereby improving cold start times.
Here's some example of my current configuration and as can be seen, this can be tedious as more libraries are included
```python
PythonFunction(
**other_atributes,
bundling=BundlingOptions(
asset_excludes=[
".git",
".idea",
".mypy_cache",
".pytest_cache",
".ruff_cache",
".venv",
".vscode",
"cdk.out",
"cdk",
"node_modules",
"tests",
".coverage",
".coveragerc",
".gitignore",
".pre-commit-config.yaml",
"app.py",
"bitbucket-pipelines.yml",
"cdk.context.json",
"cdk.json",
"coverage.xml",
"package.json",
"package-lock.json",
"poetry.toml",
"README.md",
]
),
)
```
### Proposed Solution
Add an asset_includes attribute to BundlingOptions that works similarly to asset_excludes but specifies which assets to include, and have both options mutually exclusive
### Other Information
_No response_
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.144.0
### Environment details (OS name and version, etc.)
---
Contributor guide
Research direction
Start by locating BundlingOptions in the aws-lambda-python-alpha package and tracing how asset_excludes is currently handled. Define the expected behavior for an explicit asset include list, including mutual exclusion with asset_excludes, then verify the resulting Lambda bundle contains only the requested files and directories.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, typescript
- Domain
- build-system, cloud
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100