Why is my CloudWatch canary failing with the error "Cannot find module '/opt/nodejs/node_modules/myfunction"?
Why is my Amazon CloudWatch canary failing with the error "Cannot find module '/opt/nodejs/node_modules/myfunction"?
"Why is my Amazon CloudWatch canary failing with the error "Cannot find module '/opt/nodejs/node_modules/myfunction"?ResolutionIf you don't use the structure required by CloudWatch when creating a .zip file of your function and dependencies, then you receive an error. The error message reads: Cannot find module '/opt/nodejs/node_modules/myfunction.You must create your .zip file under the nodejs/node_modules file path (such as nodejs/node_modules/myCanaryFilename.js). To create your .zip file under the correct file path, do the following:1.    Create the required structure.mkdir -p /nodejs/node_modules/2.    Copy your CloudWatch canary function to /nodejs/node_modules/.Note: The handler naming convention is filename.handler.cp CanaryFunction.js /nodejs/node_modules/cp -R /lib /nodejs/node_modules/3.    Zip your directory on the top of /nodejs.zip -r Canary.zip ./nodejs/*Note: When creating a Synthetics canary from scratch, if you have multiple .js files or script dependencies, then bundle all files into a single .zip file. Use the following folder structure: "nodejs/node_modules". For example, nodejs/node_modules/myCanaryFilename.js file and other folders and files.Related informationPackaging your canary filesFollow"