Created
February 18, 2019 00:48
-
-
Save thewrongjames/0ed5d8159b32df60fd251e7bcae79392 to your computer and use it in GitHub Desktop.
AWS lambda function code for checking the function's IP using ipify.
This file contains 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 http = require('http') | |
const options = { | |
hostname: 'api.ipify.org', | |
port: 80, | |
path: '/?format=JSON', | |
method: 'GET', | |
} | |
exports.handler = (event, context, callback) => { | |
const request = http.request(options, response => { | |
response.setEncoding('utf8') | |
response.on('data', data => { | |
console.log(JSON.stringify(data)) | |
callback(null, 'Received data.') | |
}) | |
}) | |
request.on('error', callback) | |
request.end() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment