Skip to content

Instantly share code, notes, and snippets.

@kixorz
Last active February 14, 2024 07:39
Show Gist options
  • Save kixorz/3b172e2fc3ce35421ee9 to your computer and use it in GitHub Desktop.
Save kixorz/3b172e2fc3ce35421ee9 to your computer and use it in GitHub Desktop.
Function retrieving AWS Lambda public IP address. Copy and paste this to your Lambda console, use standard permissions, execute and observe the log to see the public IP address of your Lambda function.
var http = require('http');
exports.handler = function(event, context) {
http.get('http://httpbin.org/get', function(res) {
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
console.info(body);
context.done(null);
});
}).on('error', function(e) {
console.error(e.message);
context.fail(null);
});
};
@lydiahelkinz
Copy link

can i use lambda function without going through proxy services

@kixorz
Copy link
Author

kixorz commented May 2, 2023

@lydiahelkinz Yes, you can. Depends on what you're scraping. On some sites you will be very successful, on others it will fail. If you hit sites running on say CloudFlare or a similar CDNs with adaptive firewalls and bot protections, you will need to advance your game as the default Lambdas won't be enough. You may still use Lambdas as your compute platform, but the HTTP handling and network access will need to be more advanced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment