Description
When creating Canary lambda asset resource, the bundling does not happen before the validation of "existence" of canary file is done. This blocks the usage of bundling options in many case.
Reproduction Steps
new Canary(this, props.canaryId, {
canaryName: 'testcanary',
test: Test.custom({
code: Code.fromAsset(path.join(__dirname, '../canaryScripts/), {
bundling: {
image: lambda.Runtime.NODEJS_12_X.bundlingDockerImage,
command: [
'bash',
'-c',
[
`mkdir -p /asset-output/nodejs/node_modules/`,
`cp -R /asset-input/* /asset-output/nodejs/node_modules/`,
].join(' && '),
],
user: 'root',
},
}),
handler: `canary.handler`,
}),
runtime: Runtime.SYNTHETICS_NODEJS_2_0,
});
What did you expect to happen?
I expected that the bundling would happen before CDK validates if canary file has been found from correct location of zip-file generated.
Using bundling I can run optimisation, validations, include only needed files and re-structure my code asset before creating zip file.
What actually happened?
I get error message before bundling has been executed as following: The canary resource requires that the handler is present at "nodejs/node_modules/canary.js" but not found at /Users/mypath/src/synthetics/ (https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_WritingCanary.html#CloudWatch_Synthetics_Canaries_write_from_scratch) Subprocess exited with error 1
Environment
- CDK CLI Version : 1.74.0
- Framework Version: 1.74.0
- Node.js Version: v12.18.4
- OS : macOS 11.0.1
- Language (Version): Typescript
Other
The code that triggers error is here: https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-synthetics/lib/code.ts#L135
This is 🐛 Bug Report
Activity