Invoking AWS Lambda function from a nodejs proxy,Connecting Apigee to AWS Lambda

Not applicable

We are trying to invoke a Lambda function from a node.js API proxy. The test seems to fail with a aws-sdk module not found error. The code is similar to this -

var AWS = require('aws-sdk');

...AWS access key info...

var lambda = new AWS.Lambda();

The exact error is -

{"fault":{"faultstring":"Script node executed prematurely: Error: Cannot find module 'aws-sdk'\nError: Cannot find module 'aws-sdk'\n at module.js:340\n at module.js:280\n at module.js:364\n at require (module.js:380)\n at \/organization\/environment\/api\/hello-world.js:6\n at module.js:456\n at module.js:474\n at module.js:356\n at module.js:312\n at module.js:497\n at startup (trireme.js:142)\n at trireme.js:923\n","detail":{"errorcode":"scripts.node.runtime.ScriptExitedError"}}}

We have tried using the Resource API to upload a zip of the aws-sdk node module without any success -(https://docs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/apis/%7Bapi_name%7D/revisions/%7Brevision_number%7D)

Any help will be greatly appreciated.

TIA

,

We are trying to invoke an AWS Lambda function (simple Hello World python code) from an Apigee Node.js proxy. The hello-world.js node code in Apigee looks something like this -

var AWS = require('aws-sdk');

...code for accesskey, etc.

lambda = new AWS.Lambda();

...code to invoke Lambda

On testing this we keep getting an error that aws-sdk module could not be found -

{"fault":{"faultstring":"Script node executed prematurely: Error: Cannot find module 'aws-sdk'\nError: Cannot find module 'aws-sdk'\n    at module.js:340\n    at module.js:280\n    at module.js:364\n    at require (module.js:380)\n    at \/organization\/environment\/api\/hello-world.js:6\n    at module.js:456\n    at module.js:474\n    at module.js:356\n    at module.js:312\n    at module.js:497\n    at startup (trireme.js:142)\n    at trireme.js:923\n","detail":{"errorcode":"scripts.node.runtime.ScriptExitedError"}}}

We have tried uploading a zip file containing the aws-sdk node module using the Resource API here -

https://docs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/apis/%7Bapi_name%7D/revisi...

We can see the uploaded zip files as well. However, this doesn't seem to resolve the problem of not able to find aws-sdk module.

Any ideas on what else we can try?

TIA

0 3 2,040
3 REPLIES 3

gsjurseth
Participant I

Hi,

I'm not sure exactly why it's not finding the aws-sdk module in your case, but here's a repo doing something similar that i've tested in my own org.

This repo includes a simple aws lambda setup with serverless and then an apiproxy in apigee that calls it... The whole sample relies on using kvm to store credentials which I think is not your issue, but I've run this myself and it works perfectly.

You can view it here:

https://github.com/gsjurseth/callingLambdaFromProxy

Thanks,

/geir

Not applicable

Not applicable

Hi, Where did you get that .zip file ? could you share the link?