Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@hackstudio/puppeteer-lambda-launcher

Tchangang20ISC1.0.4

Launch chromium on AWS lambda and use it with Puppeteer

puppeteer, lambda, aws, amazon, launch, chromium, chrome, headless, automation

readme

Puppeteer lambda launcher

Drive Chrome headless with Pupetteer on AWS LAMBDA. This module download and install a chromium instance on AWS lambda.

npm

Contents

  1. General
  2. Installation
  3. Setup

General

This lib has been built for web scraping and automation after working 2 days on making it working on AWS lambda.

Installation

Install with npm:

npm install --save @hackstudio/puppeteer-lambda-launcher

Setup

Use in your AWS Lambda function. Requires Node 6.10.

let ChromeInstaller = require('@hackstudio/puppeteer-lambda-launcher')

ChromeInstaller = new ChromeInstaller({ 
  accessKeyId: 'AKIAxxxxxxxxxxxx', 
  secretAccessKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 
  s3Bucket:'bucket_name_xxx', s3Key:'s3_object_name', 
  executePath:'xxxxxxxxxxxxx'
})

// accessKeyId : get it from your AWS account
// secretAccessKey : get it from your AWS account
// s3Bucket : 'bucket_name' // bucket where compressed chromium is stored. You can download it here : https://github.com/Tchangang/puppeteer-lambda-launcher/releases/tag/1.0
// s3Key : 's3_object_name' // key to retrieve object on S3. Ex: headless-chromium.tar.gz
// executePath : 'headless-chromium' // Name of executable path when chromium uncompressed 

// Setup chromium
await ChromeInstaller.setupChrome()

// if chromium is not installed, we will download, decompress it and install in /tmp folder  
const chromePath = ChromeInstaller.executablePath

// Launch puppeteer

const args = [
  '--no-sandbox',
  '--disable-gpu',
  '--disable-setuid-sandbox',
  '--single-process',
  '--headless'
]
const puppeteer = require('puppeteer')
browser = await puppeteer.launch({
  headless: true,
  executablePath: chromePath
  args:args
})

// Enjoy it :-)

Thanks to https://github.com/sambaiz/puppeteer-lambda-starter-kit for his work.

Feel free to contact me at tchangang.boris+github@gmail.com :-)