0
votes

I'm trying to create a simple application following this article, but I cannot get my Node Lambda function to find the dynamodb-geo package.

Here is what I have:

const AWS = require('aws-sdk');
const ddbGeo = require('dynamodb-geo');

exports.handler = async (event, context) => {
  // Rest of the code here
};

And the error Lambda throws is:

START RequestId: 5d40d132-040f-447d-bd76-35c4cec0236a Version: $LATEST 2019-10-05T10:04:24.719Z undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'dynamodb-geo'","stack":["Runtime.ImportModuleError: Error: Cannot find module 'dynamodb-geo'"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)","
at Object. (/var/runtime/index.js:45:30)"," at Module._compile (internal/modules/cjs/loader.js:778:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)"," at Module.load (internal/modules/cjs/loader.js:653:32)"," at tryModuleLoad (internal/modules/cjs/loader.js:593:12)"," at Function.Module._load (internal/modules/cjs/loader.js:585:3)"," at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)","
at startup (internal/bootstrap/node.js:283:19)"]} END RequestId: 5d40d132-040f-447d-bd76-35c4cec0236a REPORT RequestId: 5d40d132-040f-447d-bd76-35c4cec0236a Duration: 1146.75 ms Billed Duration: 1200 ms Memory Size: 512 MB Max Memory Used: 35 MB Unknown application error occurred Runtime.ImportModuleError

Any clue on what could be happening?

2

2 Answers

1
votes

The only included package on AWS Lambda is the aws-sdk package. Everything else (except standard node packages) needs to be packaged and uploaded with your code.

There are many tools to achieve this:

0
votes

Have you installed the package?

Using npm or yarn: npm install --save dynamodb-geo or yarn add dynamodb-geo.

Doc: https://www.npmjs.com/package/dynamodb-geo