Lambda can't find modules from outer folders when deployed with CDK

lambda reserved instances
aws lambda tutorial
aws lambda documentation
lambda function
aws lambda pricing
aws lambda example
lambda memory
lambda programming

I am deploying some apis to API Gateway using cdk. My problem is the file that contains the lambda(index.ts) can't import any files or npm modules outside that folder(folder named get-users).

I tried copying node_modules folder and other files (which were outside the folder get-users) to the folder get-users and it worked perfectly.

Example error when importing lodash is as follows,

"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'lodash'",
"stack": [
    "Runtime.ImportModuleError: Error: Cannot find module 'lodash'",

I am importing lodash as follows,

import * as _ from "lodash";

I am importing shared files as follows,

import { validator } from "./shared/validators" // This one works

import { validator } from "../../shared/validators" // This one doesn't work

AWS Lambda – Product Features, After you upload your code to AWS Lambda, you can associate your function with specific AWS resources (e.g. a particular Amazon S3 bucket, Amazon  Ecumaster Lambda to CAN controller is a compact device used to control a Bosch LSU 4.9 wideband oxygen sensor and transmit the lambda reading via CAN-BUS. Two programmable 0-5V analog signal lines are available, along with the CAN transmission.


After spending some time contemplating the very same issue I finally resorted to using webpack to build my lambda packages, which is definitely the way I would recommend.

What you would do in that case is to point your AssetCode to a directory where Webpack has previously packaged the whole thing e.g. src/your-function/build.

Additional benefit is that you can configure Webpack to minify the files, so you speed up your deployment, but also your lambda cold start.

Can Lambda Explained, WHY SHOULD YOU USE A CAN LAMBDA SENSOR? A CAN LAMBDA sensor, often referred to as an oxygen sensor, measures the level of oxygen in exhaust  Description MoTeC’s LTC (Lambda to CAN) modules monitor, control and diagnose Bosch LSU 4.9 Lambda sensors, transmitting readings on a CAN bus. When multiple LTCs are used, up to 32 Lambda sensors can be configured on a single CAN bus, allowing an ECU or logging device to simultaneously monitor numerous Lambda sensors.


I found the answer after some research. Problem was CDK not deploying the node_modules folder and other folders which are outside the folder which contains the lambda source file.

When creating the lambda file root path has to be added to the 'code' attribute so that it will take all the folders/files inside it and deploy to the lambda.

    const pathToRoot = //absolute path to the root folder
    const pathToHandler = //path to handler from root folder
    const lambdaFunction: Function = new Function(construct, name, {
        functionName: name,
        code: Code.asset(pathToRoot),
        handler: `${pathToHandler}/index.handler`,
        runtime: Runtime.NODEJS_10_X
    });

CAN Lambda - Link Engine Management, Link's CAN Lambda is an easy to use CAN module that provides digital wideband sensor Duration: 1:43 Posted: Jul 12, 2006 ECM's LambdaCAN Module is a powerful, "next-generation" wideband Lambda (and AFR, O2) measurement module with a CAN interface. In addition to providing outstanding measurement range and accuracy, LambdaCAN addresses the two principle sources of error with wideband sensor use: sensor aging and pressure sensitivity.


Ecumaster LAMBDA to CAN, Ecumaster Lambda to CAN controller is a compact device used to control a Bosch LSU 4.9 wideband oxygen sensor and transmit the lambda reading via  int n; int main() { [](){ n = 0; }(); // clang says "ok" int m; [](){ m = 0; }(); // clang says "not ok" } I just wonder: If the lambda captures nothing, is it


Serverless Framework: Lambdas Invoking Lambdas, be accomplished by adding an iamRoleStatements section under the provider property (lines 4-8 below). AWS Lambda is a compute service that lets you run code without provisioning or managing servers. AWS Lambda executes your code only when needed and scales automatically, from a few requests per day to thousands per second. You pay only for the compute time you consume - there is no charge when your code is not running.


What is AWS Lambda? - AWS Lambda, executes your code only when needed and scales automatically, from a few requests per day to thousands per second. You pay only for the compute time you consume - there is no charge when your code is not running. Lambda can also poll resources in other services that do not publish events to Lambda. For example, Lambda can pull records from an Amazon Kinesis stream or an Amazon SQS queue and execute a Lambda function for each fetched message.