Last active
May 2, 2019 01:41
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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