Skip to content

Instantly share code, notes, and snippets.

@r3-yamauchi
Last active May 2, 2019 01:41
Show Gist options
  • Save r3-yamauchi/f1b718bc4026b837210cab722ba9e01d to your computer and use it in GitHub Desktop.
Save r3-yamauchi/f1b718bc4026b837210cab722ba9e01d to your computer and use it in GitHub Desktop.
AWS Lambda Function (Node.js) から AWS IoT に publish する (aws-iot-device-sdk使用) https://blog.r3it.com/
const awsIot = require('aws-iot-device-sdk');
const device = awsIot.device({
keyPath: '9xxxx9x999-private.pem.key',
certPath: '9xxxx9x999-certificate.pem.crt',
caPath: 'root.pem',
clientId: 'iotTest',
host: 'endpoint.iot.ap-northeast-1.amazonaws.com'
});
device.on('connect', () => {
device.publish('topic_1', JSON.stringify({ message_id: 1, Message: 'Hello World' }));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment