shelfio / chrome-aws-lambda-layer

58 MB Google Chrome to fit inside AWS Lambda Layer compressed with Brotli
MIT License
637 stars 45 forks source link

What's next after creating Lambda Layer? #33

Closed wafendy closed 2 years ago

wafendy commented 3 years ago

Hi,

Is there any guide or tutorial on what to do next after successfully created this lambda layer?

I have included the layer ARN in my serverless framework configuration. Do I still need to include chrome-aws-lambda and puppeteer-core in my package.json as dependency?

wongmrdev commented 3 years ago

not sure about a good tutorial as i haven't gotten it working from layer yet.

you definitely don't need to include in lambda package,json.

Jtcruthers commented 3 years ago

Finally got this working. puppeteer-core is a dependency, chrome-aws-lambda is a dev-dependency. You'll need to put the layer arn in the template. Using this repo's published layer, I had to pin both of the aforementioned packages to v9.1.0.

Code to get the browser:

const browser =  await chromium.puppeteer.launch({
    args: chromium.args,
    defaultViewport: chromium.defaultViewport,
    executablePath: await chromium.executablePath,
    headless: chromium.headless,
    ignoreHTTPSErrors: true,
})

That's all it took for me.

vladholubiev commented 2 years ago

Just follow the guide at https://github.com/Sparticuz/chrome-aws-lambda#usage but use this layer instead of adding an NPM package dependency