Last active
February 14, 2024 07:39
-
-
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.
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
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 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
can i use lambda function without going through proxy services