Last active
January 11, 2017 22:48
-
-
Save johnypony3/f06c2f5e32646e0e985bfba0fa671979 to your computer and use it in GitHub Desktop.
a labda function that subscribes to an sns queue and pushes data to an mqtt queue
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
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
'use strict'; | |
let publishTopic = require("./publishTopic"); | |
exports.handler = (event, context, callback) => { | |
console.log('topic:', event.topic); | |
console.log('action:', event.action); | |
var topic = "***YOUR TOPIC***" + event.topic; | |
var action = event.action; | |
publishTopic([topic, action]); | |
//callback(null, "action: " + actionApi + " published to: " + topic); | |
callback(null, "{'status':'ok'}"); | |
}; |
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
"use strict" | |
var mqtt = require('mqtt'); | |
module.exports = (req, done) => { | |
var client = mqtt.connect("***YOUR ENDPOINT***") | |
client.on('connect', () => { | |
console.log("Connected"); | |
console.log(req[0]); | |
console.log(req[1]); | |
client.publish(req[0],req[1]); | |
client.end(); | |
console.log("published"); | |
//req.result = "Successfully"; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment