June 27, 2026
How to Run Playwright Tests on AWS
Learn how to run Playwright tests on AWS using EC2, containers, and managed browser grid patterns, plus when Endtest is a simpler alternative to building your own infrastructure.
Playwright is easy to start with locally, but running it reliably on AWS is a different problem. The moment you move from a laptop to cloud infrastructure, you have to think about browser dependencies, worker isolation, networking, artifact storage, test timeouts, and what happens when a node disappears mid-run. That is why many teams search for a practical way to run Playwright tests on AWS without turning their test pipeline into a second production system.
There are a few legitimate ways to do it. You can run Playwright on a single EC2 instance, package it into Docker and execute it in ECS or EKS, or connect Playwright to a cloud browser grid that sits behind your AWS environment. Each option solves a different problem, and each one introduces different maintenance cost.
This article walks through those options, shows concrete setup patterns, and explains when AWS makes sense versus when a managed platform is the simpler choice. If your team wants cloud browser execution without building and owning all of the infra yourself, a managed platform like Endtest can be the simpler alternative, especially if you care more about stable browser coverage than about running browsers on your own servers.
Why teams run Playwright on AWS
Most teams do not move browser tests to AWS because AWS is glamorous. They do it because the browser suite needs to run somewhere shared, predictable, and close to the rest of the delivery pipeline.
Common reasons include:
- CI runners on GitHub Actions or GitLab are too limited for heavy suites
- tests need more CPU or memory than a default runner provides
- multiple teams need to share a test environment
- artifacts, logs, and videos need to be collected centrally
- security rules require testing from a controlled network
- browser tests must run against internal services reachable only from a VPC
AWS is attractive because it gives you building blocks, not opinions. That flexibility is useful, but it also means you own the orchestration. Playwright is a test runner and browser automation library, not a hosted execution platform, so the burden of infrastructure remains yours. The official Playwright docs cover installation and local execution well, but production-style execution is something your team has to design around it, see the Playwright documentation.
The hard part is not starting browsers, it is making browser execution repeatable across workers, upgrades, failures, and environment drift.
The main ways to run Playwright tests on AWS
Before getting into setup details, it helps to separate the architectures.
Option 1, run Playwright directly on an EC2 instance
This is the simplest AWS pattern. You provision a Linux VM, install browsers and dependencies, clone your repo, and run tests from the machine.
Good for:
- quick experiments
- small suites
- debugging flaky failures with interactive access
- teams that want maximum control with minimum platform complexity
Tradeoffs:
- you must patch and maintain the VM
- concurrency is limited by one machine unless you add more instances
- screenshots, traces, and videos must be copied somewhere durable
- browser version drift becomes your problem
Option 2, run Playwright in Docker on ECS or EKS
This is better when you want repeatable execution and horizontal scaling. You build a test container that includes Playwright and the browser dependencies, then run one or more tasks or pods per test job.
Good for:
- CI-driven pipelines
- parallel test runs
- consistent dependencies
- ephemeral, disposable execution environments
Tradeoffs:
- more setup than EC2
- you must decide how to shard tests and collect artifacts
- container resource limits can cause browser instability if undersized
- networking to private app environments takes planning
Option 3, use AWS as the network and storage layer, but offload browser execution to a cloud grid
This can mean using AWS for private connectivity, S3 for artifacts, and maybe a self-hosted or managed browser grid for execution. The grid may sit in your VPC or outside it, depending on your compliance and routing needs.
Good for:
- large suites
- cross-browser parallelism
- centralizing browser access
- reducing how much infrastructure your team directly manages
Tradeoffs:
- if self-hosted, the grid still needs upkeep
- if managed, you depend on a vendor platform
- network topology can be more complicated than local CI
Start with the simplest viable architecture
A lot of AWS test infrastructure fails because teams build for the future before they have a stable baseline. The better pattern is to start simple, prove reliability, then scale.
A good progression
- Run the suite locally and in CI
- Move it to one EC2 instance for environment parity
- Containerize it for repeatability
- Add parallelism or a grid only when the suite justifies it
This matters because a flaky suite on one box will usually stay flaky on ten boxes. Scaling a bad setup only creates more noisy failures.
Running Playwright on a single EC2 instance
If your main goal is to get a browser suite running on AWS quickly, EC2 is often the shortest path.
Example setup
Use a recent Ubuntu AMI, then install Node.js, Playwright, and browsers. The exact package versions depend on your project, but the setup pattern looks like this:
sudo apt-get update
sudo apt-get install -y nodejs npm
npm ci
npx playwright install --with-deps
npx playwright test
If you are using a prebuilt image in a CI job, you may not need to install system dependencies every run. If you are using a long-lived EC2 host, you probably should script the setup so the environment is reproducible.
Useful EC2 practices
- use an IAM role rather than static AWS keys on the machine
- store test artifacts in S3, not only on the instance disk
- separate the browser host from the app under test if possible
- use CloudWatch logs or a log shipper for test output
- keep the instance ephemeral when possible, rebuild instead of hand-patching
Example artifact upload to S3
bash aws s3 cp playwright-report s3://my-test-artifacts/playwright-report/ –recursive aws s3 cp test-results s3://my-test-artifacts/test-results/ –recursive
When EC2 is enough
EC2 works well when the suite is small, the team wants a machine they can SSH into, and the main pain point is browser dependencies rather than scale. It is not ideal when you need lots of parallel runs or strict isolation between jobs.
Running Playwright in Docker on AWS
For most teams, containerizing browser tests is a better long-term answer than running them directly on a host.
A container gives you a controlled filesystem, repeatable dependencies, and a clean way to run one test job per container. On AWS, that usually means ECS for simpler orchestration or EKS if your organization already standardizes on Kubernetes.
A minimal Dockerfile
dockerfile FROM mcr.microsoft.com/playwright:v1.52.0-jammy WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . CMD [“npx”, “playwright”, “test”]
This is a common pattern because Microsoft publishes Playwright base images with browsers and dependencies already installed. That reduces the amount of machine setup you have to own.
Why containers help
- every test job starts from the same base image
- browser dependencies are pinned in the image version
- scaling out is easier because each worker is disposable
- debugging is easier when the container image is part of the test artifact trail
What can still go wrong
Containers do not magically solve flaky tests. Common failures include:
- too little memory for Chromium under load
- CPU throttling in oversized suites
- race conditions exposed by faster parallel execution
- missing system fonts or locale packages
- download limits or network restrictions in private subnets
If your container is too small, browser startup can fail or tests can appear nondeterministic. A browser test suite is heavier than an API test suite, so capacity planning matters.
A practical ECS pattern for Playwright
ECS is usually simpler than EKS for browser tests if your team just wants to launch jobs from CI and retrieve results.
A common flow looks like this:
- Build a Playwright test image
- Push it to Amazon ECR
- Trigger an ECS task from your CI pipeline
- Mount or upload artifacts to S3
- Fail the pipeline if the task exits non-zero
GitHub Actions example triggering a containerized run
name: playwright-tests
on: push: branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: $
aws-secret-access-key: $
aws-region: us-east-1
- name: Run task
run: |
aws ecs run-task
–cluster playwright-tests
–launch-type FARGATE
–task-definition playwright-runner
In practice, you will probably add waiting logic, inspect the task exit code, and fetch logs from CloudWatch. The important point is that the CI system should treat the container as an execution unit, not as a stateful server.
How to handle parallelism and sharding
Once the suite gets slow enough to hurt feedback time, parallel execution is usually the next step. Playwright supports parallel workers, but the best strategy depends on the kind of failures you see.
Parallel workers inside one job
This is the easiest place to start. You can let Playwright use multiple workers on one machine or one container:
bash npx playwright test –workers=4
This is fine for moderate suites, but browser memory use can spike quickly, especially if each test opens its own context and downloads large assets.
Sharding across jobs
For larger suites, it is often better to split the suite into shards and run several jobs in parallel across ECS tasks, EC2 instances, or CI runners.
bash npx playwright test –shard=1/4 npx playwright test –shard=2/4 npx playwright test –shard=3/4 npx playwright test –shard=4/4
Sharding reduces wall-clock time, but it also makes artifact aggregation and failure triage more complex. You need a plan for merging reports, collecting traces, and identifying which shard ran which test.
Avoiding flaky parallel behavior
If tests depend on shared data, parallelization can surface hidden coupling. Common problems include:
- reusing the same user account across tests
- tests that create identical records
- cache warmup effects changing timing
- global app state not reset between runs
The fix is usually to make each test self-contained, use isolated test data, and avoid depending on order.
Networking and private environments on AWS
One reason teams choose AWS for browser testing is network access. Your test runner may need to reach an app in a private subnet, a staging environment behind a firewall, or internal services that are not exposed publicly.
Typical patterns
- run the browser job in the same VPC as the app
- use a private ECS task with security group access to the app
- route through a VPC endpoint or internal load balancer
- keep secrets in AWS Secrets Manager or SSM Parameter Store
If you are testing an internal app, network design matters more than browser design. A perfectly tuned Playwright suite is useless if the runner cannot reach the environment reliably.
Common connectivity mistakes
- opening too many outbound permissions instead of using targeted security groups
- forgetting DNS resolution inside private subnets
- placing test workers in the wrong availability zone or subnet
- relying on public endpoints for apps that behave differently when routed privately
Managing browser versions and dependency drift
Browser instability often appears after infrastructure changes, not test changes. On AWS, this is especially true if your hosts are long-lived or manually maintained.
Keep the runtime pinned
Prefer a pinned Playwright package version and a pinned base image version. That reduces surprise upgrades.
Rebuild images regularly
Even pinned containers eventually need rebuilds for OS patches and browser updates. Rebuild on a schedule so your runtime does not drift far from what developers use locally.
Watch for Linux library mismatches
If you are not using the official Playwright container image, you may need extra dependencies for fonts, audio libraries, or GTK packages. Missing system libraries are a common source of browser launch failures on fresh EC2 hosts.
Artifacts, tracing, and debugging failures
One of Playwright’s best features is its debugging output, especially traces, screenshots, and videos. But those files only help if you store them somewhere accessible after the job ends.
Configure artifacts in Playwright
import { defineConfig } from '@playwright/test';
export default defineConfig({ use: { trace: ‘on-first-retry’, screenshot: ‘only-on-failure’, video: ‘retain-on-failure’ } });
Store artifacts outside the runner
If you are running on EC2 or ECS, move the report directory to S3 or attach it to your CI system. Otherwise, a terminated instance deletes the evidence you need to debug the failure.
When browser tests fail in the cloud, the artifact strategy is part of the test strategy.
When AWS is a good fit, and when it is not
AWS is a good fit when you need control, private networking, or a way to scale browser jobs with your own operational model. It is less compelling when your real problem is simply, “we need browser execution without becoming an infra team.”
AWS makes sense when
- you already operate heavily in AWS
- you need private access to internal environments
- you want to build a custom pipeline around browser jobs
- your team is comfortable owning Docker, IAM, networking, and observability
AWS is probably overkill when
- you only need reliable cross-browser execution
- the team is small and infrastructure maintenance is already a burden
- browser infrastructure keeps distracting engineers from product work
- you want QA, product, or design contributors to participate directly in test creation
That last point is where a managed platform becomes interesting. A platform like Endtest is designed as a managed, agentic AI Test automation environment with low-code and no-code workflows, so teams do not have to build and maintain their own AWS browser execution stack. It is especially relevant if you want cloud browser testing without spending time on CI wiring, browser host upkeep, or grid management. Endtest’s AI Test Creation Agent creates editable platform-native steps inside the platform, which is a different operating model from maintaining a Playwright runtime in AWS.
AWS Playwright versus managed browser execution
A useful way to think about the decision is to compare ownership, not feature lists.
If you run Playwright on AWS yourself
You own:
- browser images or EC2 setup
- worker scaling
- test isolation
- artifact storage
- retries and failure handling
- upgrades and security patches
- network access to private environments
If you use a managed platform
You mostly own:
- the test logic
- the app under test
- the reporting policy
- the governance around who can edit tests
This is why some teams start with AWS and later move to a managed browser testing platform once the operational cost becomes visible. Others start with a managed option from day one because their bottleneck is test creation and maintenance, not infrastructure design.
If you are evaluating that tradeoff directly, the Endtest comparison page on Endtest vs Playwright is worth a look, especially if your team wants broader collaboration and a managed execution layer instead of building and supporting AWS-based browser workers.
A decision checklist for your team
Use this short checklist before you standardize on an AWS approach:
- Do we need private network access to the app under test?
- Do we already have ECS, EKS, or EC2 operational patterns we can reuse?
- Will the suite run often enough to justify infrastructure ownership?
- Do we need easy artifact retention and trace debugging?
- Is the team prepared to maintain browser versions and machine images?
- Do we want developers only, or also QA and non-coders, contributing to test creation?
If the answers point toward control and customization, AWS is a reasonable choice. If the answers point toward reducing operational burden, a managed browser platform is often the better fit.
Recommended implementation pattern
If you are starting from scratch, this is the most practical sequence:
- Package Playwright in the official Docker image
- Run one container per CI job on ECS or a similar AWS service
- Keep browser versions pinned
- Upload traces, screenshots, videos, and HTML reports to S3
- Add sharding only after the suite is stable
- Revisit whether you still want to own the infra once the suite grows
That sequence gives you enough structure to scale without overengineering the first version.
Final thoughts
To run Playwright tests on AWS well, you need to solve more than browser startup. You need a repeatable runtime, artifact retention, reliable networking, and a model for parallelism that does not multiply flaky behavior. EC2 works for quick wins and debugging. Docker on ECS or EKS is better for repeatable execution and scaling. A cloud grid or managed platform becomes attractive when the browser infrastructure itself becomes the thing you are testing and maintaining.
If you want maximum control, AWS can be a solid foundation for Playwright. If you want cloud browser execution without building and owning that foundation, Endtest is a simpler alternative to consider, especially for teams that want a managed platform with agentic AI-assisted test creation and less infrastructure overhead.
The right choice is not the one with the most moving parts. It is the one your team can keep reliable six months from now.