An example online screenshot application using AWS Lambda Layers on the Serverless Framework which is the base for the following blog post
The application uses chrome-aws-lambda as a lambda layer when deployed to the cloud which allows us to use Chromium and Puppeteer to open the desired webpage within a lambda in a headless browser, generate the screenshot, and store it in S3 (returning the download path in the API response)
In the root folder install the dependencies using the command npm i (Node version v12.14.0).
The application has been setup so you can run this locally without the need to deploy to AWS using the following command:
npm run offline
This will spin up the API locally using the serverless-offline plugin, and the generated screenshots are stored in a local S3 emulator using the serverless-s3-local plugin.
There is a Postman collection in the folder ./postman which can be imported and used (for both local and deployed versions)
To deploy to AWS run the following command npm run deploy:devlop which will deploy the solution to the cloud. You can then use the Postman file to hit the endpoint with the correct payload.
To remove the full application from the cloud run the command npm run remove:develop
