Created
April 1, 2016 03:12
-
-
Save andrew-templeton/db3f74dd6ce7dc5bac1442a721ce3099 to your computer and use it in GitHub Desktop.
lambda function to test the IP of your lambda as seen by ifconfig.co
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
var http = require('http'); | |
exports.handler = function (event, context) { | |
http.get('http://ifconfig.co', function (res) { | |
var buff = []; | |
console.log('Got response: %s', res.statusCode); | |
res.on('data', function (chunk) { | |
buff.push(chunk); | |
}); | |
res.on('end', function () { | |
console.log('Found: %s', buff.join('')); | |
context.done(); | |
}); | |
res.on('error', function (err) { | |
console.error('Got error: %s', e.message); | |
context.fail(); | |
}); | |
}).on('error', function (e) { | |
console.log('Got error: %s', e.message); | |
context.fail(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment