Skip to content

Instantly share code, notes, and snippets.

@res0nat0r
Created October 4, 2022 18:50
Show Gist options
  • Save res0nat0r/a20f2ae9fb88b4aac3f146e55c6710eb to your computer and use it in GitHub Desktop.
Save res0nat0r/a20f2ae9fb88b4aac3f146e55c6710eb to your computer and use it in GitHub Desktop.
Lambda network connectivity tester
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