Reader small image

You're reading from  Learning AWS IoT

Product typeBook
Published inJan 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788396110
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Agus Kurniawan
Agus Kurniawan
author image
Agus Kurniawan

Agus Kurniawan is an independent technology consultant, author, and lecturer. He has over 18 years' experience working on various software development projects, including delivering training courses and workshops, and delivering technical writing. He has done a few research activities related to wireless networking, software, and security in multiple universities. Currently, he is pursuing a Ph.D. program in Computer Science in Germany. He has previously written five books for Packt.
Read more about Agus Kurniawan

Right arrow

Accessing AWS Lambda from IoT devices


All API SDK for accessing AWS IoT, including AWS Greengrass, can be obtained on the software menu from AWS IoT Management Console. You can install it based on your device and runtime platforms.

In this section, I will show you how to invoke Lambda from AWS Greengrass Core. For testing, I used the Node.js application. You should install the aws-sdk library for Node.js. You also need to access the key ID and secret access key from the AWS IAM.

Please write the following complete program:

var AWS = require('aws-sdk');
AWS.config.update({region:'<region>'});

var accessKeyId = '<accessKeyId>'
var secretAccessKey = '<secretAccessKey>';
AWS.config.update({accessKeyId: accessKeyId, secretAccessKey: secretAccessKey});

var lambda = new AWS.Lambda();
var params = {
 FunctionName: '<lambda-function-arn>', 
 Payload: '{"msg": "this is testing"}'
};
lambda.invoke(params, function(err, data) {
 if (err) console.log(err, err.stack); 
 else console...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning AWS IoT
Published in: Jan 2018Publisher: PacktISBN-13: 9781788396110

Author (1)

author image
Agus Kurniawan

Agus Kurniawan is an independent technology consultant, author, and lecturer. He has over 18 years' experience working on various software development projects, including delivering training courses and workshops, and delivering technical writing. He has done a few research activities related to wireless networking, software, and security in multiple universities. Currently, he is pursuing a Ph.D. program in Computer Science in Germany. He has previously written five books for Packt.
Read more about Agus Kurniawan