https://github.com/danielpaulus/ff_lambda_2
https://github.com/danielpaulus/ff_lambda_2
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/danielpaulus/ff_lambda_2
- Owner: danielpaulus
- License: mit
- Created: 2021-08-24T13:59:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-01T12:23:24.000Z (over 3 years ago)
- Last Synced: 2025-01-15T10:57:31.344Z (4 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Playwright on AWS Lambda
This is an example project for running Playwright on AWS Lambda using the newly released features of running custom container images as Lambda functions.
I also wrote [a post about Playwright on AWS Lambda](https://www.larihaataja.com/running-e2e-tests-playwright-aws-lambda) to my Hashbode blog.
**NOTE! Currently only Chromium and WebKit browser are working. Firefox requires some more tuning...**
# How to use this
## Requirements
- [Docker](https://www.docker.com/)
- [AWS Command line interface](https://aws.amazon.com/cli/) installed and [configured](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html) (if deploying to AWS)## Locally with Docker
Build docker container image
```
docker build -t playwright-aws-lambda-example:latest .
```Run container
```
docker run -p 9000:8080 playwright-aws-lambda-example:latest
```Invoke function
```
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
```## Deploying to AWS Lambda
In the following examples, replace `YOUR_AWS_ACCOUNT_ID` with your AWS Account Id.
Create repository on AWS ECR (Elastic Container Registry)
```
aws ecr create-repository --repository-name playwright-aws-lambda-example --image-scanning-configuration scanOnPush=true
```Tag docker image for ECR repository
```
docker tag playwright-aws-lambda-example:latest YOUR_AWS_ACCOUNT_ID.dkr.ecr.eu-west-1.amazonaws.com/playwright-aws-lambda-example:latest
```Login
```
aws ecr get-login-password | docker login --username AWS --password-stdin YOUR_AWS_ACCOUNT_ID.dkr.ecr.eu-west-1.amazonaws.com
```Push image to ECR
```
docker push YOUR_AWS_ACCOUNT_ID.dkr.ecr.eu-west-1.amazonaws.com/playwright-aws-lambda-example
```Create and deploy an AWS Lambda function with your newly created container image! :rocket: