Closed krisb closed 2 years ago
I used npx cdkdx create app <appName>
as per the readme and also in the readme it mentions that cdk.json
contains:
// cdk.json
{
"app": "cdkdx node src/my-app.ts"
}
However, if I change this to:
// cdk.json
{
"app": "cdkdx node lib/my-app.js"
}
things are working.
Is this the correct approach?
The Code path must be correct at runtime and point to the folder with the index.js
new Function(this, 'Lambda1', {
runtime: Runtime.NODEJS_12_X,
handler: 'index.handler',
code: Code.fromAsset(path.join(__dirname, 'lambdas', 'lambda1')), // Runtime => lib/lambdas/lambda1
});
You can use the following for a cdk app
...
code: Code.fromAsset(path.join(process.env.LAMBDAS as string, 'lambda1')),
...
The correct cdk.json is:
{
"app": "cdkdx node src/my-app.ts"
}
I'm using the latest version of cdkdx (1.1.0) and cdk (1.123.0).
When I deploy a stack I see that the lambda is built in the output, e.g.
hello-world/index.js ⏤ 1.32 kB
But the asset folder under
cdk.out
only contains theindex.ts
file. Once deployed, the same files are visible in the code source on the lambda console and when testing I get the error message of"index.handler is undefined or not exported
I can find
index.js
locally underlib
, and I was expecting this to be in thecdk.out
asset folder and also uploaded.Am I missing something obvious?