Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I am going through a basic AWS on how to create a lambda function:

In this example we are creating an image re-sizing service, one way to trigger it is to listen for some image to be pushed to an S3 bucket and then lambda function will be executed.

But I am trying to understand how to invoke this Lambda function from my nodejs app when the user sends an image to my node server, I send this image to aws lambda via REST API to be re-sized and then receive the new image location as a response.

Is there any kind of example I can follow? I am more interested in the actual invocation part since I already have my lambda service up and running.


1 Answer

0 votes
by (44.4k points)

Using AWS Javascript SDK, you can invoke Lambda directly because of the node.js server (

To invoke from your server:

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

// you shouldn't hardcode your keys in production! See

AWS.config.update({accessKeyId: 'akid', secretAccessKey: 'secret'});

var lambda = new AWS.Lambda();

var params = {

  FunctionName: 'myImageProcessingLambdaFn', /* required */



lambda.invoke(params, function(err, data) {

  if (err) console.log(err, err.stack); // an error occurred

  else     console.log(data);           // successful response


AWS SDK documentation is here:

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories