Skip to content

Instantly share code, notes, and snippets.

@johntitus
Created October 2, 2015 00:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save johntitus/182d7be6876ec162c9e7 to your computer and use it in GitHub Desktop.
Save johntitus/182d7be6876ec162c9e7 to your computer and use it in GitHub Desktop.
Get the public ip address of an AWS Lambda
var http = require('http');
exports.handler = function( event, context ){
http.get({'host': 'api.ipify.org', 'port': 80, 'path': '/'}, function(resp) {
resp.on('data', function(ip) {
context.succeed(ip.toString());
});
resp.on('error', context.fail);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment