Recommended Free Tools
To take a Playwright screenshot in AWS Lambda, package a Chromium build and its Linux dependencies for the function’s runtime and architecture, navigate to the target page, and save the image under /tmp. For images that must persist beyond the invocation, upload them to S3; /tmp is temporary storage. The code below shows the capture flow, while the deployment package must supply a Chromium executable that actually works in your Lambda environment.
Capture a page and save its screenshot
Playwright’s Page API supports navigation followed by page.screenshot({ path }). This Node.js handler illustrates that flow and closes the browser even if navigation or capture fails:
const { chromium } = require('playwright');
exports.handler = async (event) => {
let browser;
try {
browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
await page.goto(event.url, { waitUntil: 'load' });
const image = await page.screenshot({ path: '/tmp/screenshot.png' });
// Upload image to S3 or return it according to your function's interface.
return { statusCode: 200, body: 'Screenshot captured' };
} finally {
await browser?.close();
}
};
This is a capture-flow example, not a complete deployment recipe. It assumes chromium resolves to a Lambda-compatible executable and that the required browser libraries are present. The regular Playwright package and a stock browser installation do not, by themselves, guarantee compatibility with Lambda. See the Playwright screenshot API documentation.
For a real endpoint, validate the input URL for your use case, choose an appropriate navigation-ready condition, and define how errors and output are handled. Returning a status message, as in the example, does not return the screenshot bytes; the image is written to /tmp/screenshot.png.
#1 Best Overall
Choose when the page is ready
waitUntil: 'load' waits for the page’s load event. Some applications populate important content afterward. In that case, use a meaningful application-specific condition, such as waiting for a locator that indicates the content is rendered. Avoid relying on arbitrary long sleeps when a concrete readiness signal is available. The right signal depends on the site being captured.
Package Chromium for Lambda
The function needs more than application code: it needs a Chromium executable and compatible Linux shared libraries. Choose a packaging method that suits the browser’s size and the level of control you need over its build.
Container image
A Lambda container image is often a practical choice when Chromium and its libraries are cumbersome to fit into a ZIP package. Include the application, Playwright runtime package, compatible Chromium build, and required libraries. AWS Lambda base images provide the Lambda runtime components; if you use another base image, include the appropriate runtime interface client. Ensure the browser files are readable and executable by Lambda’s default least-privileged user.
Rank #2
Build a single-architecture image for the function’s target, either linux/amd64 or linux/arm64. Push it to Amazon ECR in the same AWS Region as the function. Pushing a new image to an existing tag does not itself update the deployed Lambda function: perform the function code update after publishing the image. AWS documents the build and deployment flow in its Node.js Lambda container image guide.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →ZIP package or Lambda layer
A ZIP package or layer can work if the browser and its libraries fit the deployment limits and were built for a compatible Linux environment and architecture. Browserless published a DIY ZIP/layer example on April 29, 2024; its package commands are vendor-authored and should be checked against your current runtime and browser build before use. The playwright-aws-lambda package listing describes Chromium-only support and runtimes through Node.js 20. Treat that as package-specific historical information, not a guarantee of compatibility with newer Lambda runtimes; check maintenance and test the exact target architecture.
Hosted browser
A hosted browser pool can remove Chromium packaging and maintenance from the function, but adds a network dependency and vendor-specific operational considerations. Browserless describes this option in its Lambda article. The available evidence does not establish that hosted browsers are universally faster or cheaper than running Chromium in Lambda.
Deliver the screenshot outside the invocation
Lambda’s /tmp directory is writable temporary storage, not durable object storage. Use it for the screenshot file and upload the file to S3 if it needs to remain available after the execution environment is discarded. Grant the function only the S3 permissions it needs.
You can also return image bytes through the caller’s interface when its response-size and latency constraints permit. Lambda documents a 6 MB synchronous request and response payload limit for ordinary buffered invocations, with separate limits for streamed responses. For larger screenshots, storing the image in S3 and returning a reference is generally a more suitable design. See AWS Lambda quotas.
Free tools Windows power users keep installed
One-click scans. No signup required.
Set Lambda resources for browser work
Browser startup, page rendering, and image transfer all consume the function’s execution time and resources. AWS’s Lambda quota documentation lists these relevant limits:
| Setting or limit | Documented value | What it means for screenshots |
|---|---|---|
| Function timeout | Up to 900 seconds (15 minutes) | Leave time for browser startup, navigation, rendering, and delivery; the maximum is a service limit, not a recommended timeout. |
| Memory | 128 MB to 10,240 MB | CPU allocation increases with memory. Measure representative pages and tune rather than assuming the minimum is enough. |
| Temporary storage | 512 MB to 10,240 MB | Size /tmp for image output and any browser cache or temporary files your workload needs. |
| ZIP deployment contents | 250 MB uncompressed, including layers | Check the combined uncompressed package and layers against the limit. |
| Container image | Up to 10 GB uncompressed | Provides substantially more packaging headroom for a browser-heavy dependency set. |
These are AWS service limits, not performance measurements. A page’s resource demands vary, so test with representative URLs and the browser build you intend to deploy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Secure and troubleshoot the capture function
Validate URLs and permissions
If an event supplies the URL, restrict it to the sites or URL patterns your application is intended to capture. An unrestricted public screenshot endpoint can be abused as a fetch proxy. If the function writes to S3, use least-privilege IAM permissions and avoid exposing objects more broadly than needed.
Common failures and fixes
- Browser launch fails: Check that the Chromium executable and its Linux shared libraries are included, match the Lambda runtime and architecture, and are accessible to the Lambda user. A browser installation that works on a developer workstation may not work in the Lambda image.
- Function cannot find Chromium: Confirm the executable path configured by the selected browser package or build. The example uses
chromium.launch()without a custom path, so it only works when that package’s expected executable is available. - Image is missing or disappears: Confirm that the screenshot path is under writable
/tmp. Upload it to S3 or return the bytes during the invocation if it must reach another system; do not treat the temporary file as durable storage. - Capture times out or misses content: Check whether the page is still loading or renders important content after the load event. Wait for a page-specific selector or other meaningful readiness condition, and configure a timeout that allows for navigation and rendering.
- Deployment update appears unchanged: After pushing a revised image to ECR, update the Lambda function’s code to use the image. Updating the ECR tag alone does not update the deployed function.
- Function runs out of memory, time, or temporary space: Profile representative pages, then adjust memory, timeout, and
/tmpstorage within Lambda’s limits. Browser workloads can vary substantially by page. - Response is too large: A buffered synchronous Lambda response is subject to the documented 6 MB limit. Store a large screenshot in S3 and return a reference instead.
Close the browser in a finally block, as shown above, so navigation or screenshot errors do not leave browser processes behind in a reused execution environment. Return a controlled error for failures rather than leaking implementation details to callers.
Best Value
Or skip the browser setup
ScreenshotNeo offers a website screenshot API and MCP server if you would rather not package Chromium in Lambda. Its one-call API can return a screenshot or PDF; the request below saves a WebP image. See the ScreenshotNeo documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include page-verdict and billing headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.
Frequently Asked Questions
Can I use Playwright’s regular Chromium download in Lambda without changes?
Not necessarily. The browser executable and its Linux libraries must be compatible with the Lambda runtime and architecture; test the exact build you deploy.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Does the handler example return the screenshot image?
No. It saves the file to /tmp/screenshot.png and returns a text message. Upload the file or return image bytes according to your function’s interface.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




