Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-lambda-python-alpha: BundlingOptions exclude all assets and explicit include #30652

Open
2 tasks
mayconfrr opened this issue Jun 24, 2024 · 1 comment
Open
2 tasks
Labels
@aws-cdk/aws-lambda-python feature-request A feature should be added or improved. p2

Comments

@mayconfrr
Copy link

mayconfrr commented Jun 24, 2024

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

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.)


@mayconfrr mayconfrr added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 24, 2024
@pahud
Copy link
Contributor

pahud commented Jul 1, 2024

Makes sense to me. Please help us prioritize this feature request with 👍 and we welcome pull requests.

@pahud pahud added p2 and removed needs-triage This issue or PR still needs to be triaged. labels Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-python feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants