aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.5k stars 3.85k forks source link

aws_lambda: Code.from_asset requires string as the first argument. #30457

Open InvincibleRMC opened 3 months ago

InvincibleRMC commented 3 months ago

Describe the feature

Make Code.from_asset first argument optional.

Use Case

The reason for this is when create a lambda dependency layer you have no reason to copy in files. To avoid copying in files I had to create an empty directory.

code=Code.from_asset('empty',
                                              bundling=BundlingOptions(
                                                    image=Runtime.PYTHON_3_11.bundling_image,
                                                    # Must follow this file structure
                                                    # https://docs.aws.amazon.com/lambda/latest/dg/python-layers.html
                                                    command=["bash", "-c", "pip install pygeohash==1.2.0 -t /asset-output/python/"]

Proposed Solution

Either create a more specific Code.from_bundle or make the path argument optional.

Other Information

No response

Acknowledgements

CDK version used

2.142.1 (build ed4e152)

Environment details (OS name and version, etc.)

Ubuntu 22.04, Python3.11

pahud commented 3 months ago

Yeah, this makes sense to me. Thank you for the report and we welcome the pull requests.