Created
October 4, 2022 18:50
-
-
Save res0nat0r/a20f2ae9fb88b4aac3f146e55c6710eb to your computer and use it in GitHub Desktop.
Lambda network connectivity tester
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('https'); | |
exports.handler = async (event, context) => { | |
return new Promise((resolve, reject) => { | |
const options = { | |
host: 'httpbin.org', | |
path: '/uuid', | |
port: 443, | |
method: 'GET' | |
}; | |
const req = http.request(options, (res) => { | |
let data = ''; | |
// A chunk of data has been recieved. | |
res.on('data', (chunk) => { | |
data += chunk; | |
}); | |
// The whole response has been received. Print out the result. | |
res.on('end', () => { | |
console.log(JSON.parse(data)); | |
}); | |
}); | |
req.write(''); | |
req.end(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment