4

Is it possible for a Lambda function to launch a "headless" browsing session? I know it's capable of executing code, but I'm not sure if it's able to do something like execute a browsing session with Webdriver scripts, or even spin up an EC2 instance with Webdriver on which it could run those scripts.

The reason I'm trying to do this is because I have an Amazon IoT button, and I'm trying to get it to launch a headless browsing session using Webdriver to order a product off Amazon.

Mark B
  • 183,023
  • 24
  • 297
  • 295
priorww1
  • 193
  • 7
  • Lambda probably isn't a great idea for this kind of thing. Make sure you do your math on how expensive it'd be to use Lambda for this vs. just running an EC2 instance or two. – Undo Oct 26 '16 at 19:40
  • 4
    Not sure why Undo thinks this is a bad idea. I think it's a great idea. I don't know about using selenium-webdriver though, but you can definitely use PhantomJS http://stackoverflow.com/questions/34645131/how-do-i-run-phantomjs-on-aws-lambda-with-nodejs – Mark B Oct 26 '16 at 19:41
  • @MarkB I could be (probably am) wrong, but my reasoning is that since Lambda is billed in 100ms increments, your tasks don't have to be very long before Lambda becomes more expensive than EC2. I haven't run the numbers, though, and this is all dependent on overall volume. – Undo Oct 26 '16 at 19:46
  • @MarkB This is exactly what I was looking for. Thank you! – priorww1 Oct 26 '16 at 20:32

1 Answers1

3

Yes, you can launch external processes using Lambda, including PhantomJS & Webdriver. You would just create a deployment bundle that includes the executable and configuration and then start it using child_process.spawn.

Ryan Gross
  • 6,423
  • 2
  • 32
  • 44