aws / aws/aws-cdk

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

Open
#30,457 1 comment 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-lambda effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

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

```python
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

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.142.1 (build ed4e152)

### Environment details (OS name and version, etc.)

Ubuntu 22.04, Python3.11

Contributor guide

Open the contributing guide

Research direction

Start at the Code.from_asset entry point and trace how its first argument is validated when BundlingOptions is supplied. Compare the requested optional-path behavior with the existing API and tests; done means a dependency layer can be bundled from the shown command without creating an empty directory, while preserving current asset behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.