aws / aws/aws-cdk

aws-cdk-lib: CustomResourceProvider does not allow .mjs ECMAScript modules

Open
#31,049 1 comment 0 reactions 0 assignees View on GitHub
@aws-cdk/custom-resources effort/small feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the feature

When creating a CustomResourceProvider with NODEJS_20_X runtime and specifying a codeDirectory that contains an index.mjs file, the deployment fails. ("Error: cannot find codeDirectory/index.js").

### Use Case

Since it is the default now to have an index.mjs ECMAScript module when you create a node 20.x Lambda Function in the AWS console, I would expect that this is possible for CDK Custom Resources as well.

### Proposed Solution

_No response_

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

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

MacOS Sonoma

Contributor guide

Open the contributing guide

Research direction

Start at the CustomResourceProvider implementation and trace how codeDirectory is resolved for the NODEJS_20_X runtime. Reproduce the deployment case with a directory containing index.mjs and compare it with the current index.js expectation. Done means a CustomResourceProvider using that runtime can deploy an index.mjs module without the reported cannot-find error, with relevant tests updated.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.