Skip to content

Instantly share code, notes, and snippets.

@thewrongjames
Created February 18, 2019 00:48
Show Gist options
  • Save thewrongjames/0ed5d8159b32df60fd251e7bcae79392 to your computer and use it in GitHub Desktop.
Save thewrongjames/0ed5d8159b32df60fd251e7bcae79392 to your computer and use it in GitHub Desktop.
AWS lambda function code for checking the function's IP using ipify.
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