Skip to content

vittorio-nardone/selenium-chromium-lambda

Repository files navigation

λ selenium-chromium-lambda

How to run automated (Selenium) Headless Chromium in AWS Lambda.

Read full article https://www.vittorionardone.it/en/2020/06/04/chromium-and-selenium-in-aws-lambda

An example about taking a full height screenshot of a given webpage in Python.

BINARIES UPDATE

I’ve updated project to successfully use:

  • Chromium 86.0.4240.0
  • Chromedriver 86.0.4240.22.0
  • Selenium 3.14

LAYERS - NEW!

A Lambda Layer is used to include all required binaries and libs.

Contents

Selenium wrapper to get a full height screenshot of a given webpage. Code is in src/webdriver_screenshot.py.

Lambda source code is in src/lambda_function.py. It's a sample function using wrapper to get screenshot of a given URL. Fixed size and full height size screenshots are saved to a S3 bucket.

CloudFormation template to create Lambda stack. Please change WebSite parameter to your favorite URL.

Commands

Run these commands in sequence:

make lambda-layer-build to prepare archive for AWS Lambda Layer deploy (layer.zip)

make lambda-function-build to prepare archive for AWS Lambda deploy (deploy.zip)

make BUCKET=<your_bucket_name> create-stack to create CloudFormation stack (lambda function, layer and IAM role)

Offline execution (using Docker)

make docker-build to prepare Docker image for AWS Lambda offline execution

make lambda-run to execute AWS Lambda in Docker

Credits

Inspired by this awesome project

About

λ How to run automated (Selenium) headless Chromium in AWS Lambda

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published