Skip to content

Tooling that allows puppeteer v1.4.0 to run within the AWS Lambda environment.

Notifications You must be signed in to change notification settings

sean-hill/aws-puppeteer-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Puppeteer Lambda

Execute puppeteer scripts within the AWS Lambda environment.

Usage

const puppeteer = require('puppeteer')
const { extract, cleanup } = require('aws-puppeteer-lambda')

;(async () => {
  // Extract the headless chrome executable and return its path.
  // If a previous Lambda invocation has extracted the executable, it will be reused.
  const executablePath = await extract()
  
  // Initialize a new browser instance with puppeteer to execute within Lambda.
  const browser = await puppeteer.launch({
    ignoreHTTPSErrors: true,
    args: [
      '--disable-dev-shm-usage',
      '--disable-gpu',
      '--single-process',
      '--no-zygote',
      '--no-sandbox'
    ],
    executablePath
  })
  
  // Run puppeteer script
  const page = await browser.newPage()
  await page.goto('https://example.com')
  await page.screenshot({path: 'example.png'})
  await browser.close()
  
  // Cleanup the TMP folder after each execution otherwise Chromium's
  // garbage will cause the Lambda container to run out of space.
  await cleanup()
})()

Test

$ npm test

About

Tooling that allows puppeteer v1.4.0 to run within the AWS Lambda environment.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published