Updated Nov 23, 20266 min read

Replace Heroku Review Apps with Preview Environments on AWS

How Heroku review apps map to a per-pull-request setup when production moves to AWS: what app.json, postdeploy and add-ons did for you, what a hand-built version needs, and a TypeScript version where each pull request gets its own environment.

Illustration for Replace Heroku Review Apps with Preview Environments on AWS

A Heroku review app is a full copy of the app for one pull request, with its own URL, built from the branch and configured by app.json. It is one of the first things teams miss after moving production to AWS, because AWS has nothing that creates an environment when a pull request opens.

This guide covers what review apps did, what a hand-built replacement involves, and how the same flow works when the platform creates the environment.

What did Heroku review apps do for you?

Per the review apps documentation, checked on November 23, 2026, a review app is created from a pipeline when a pull request opens, deploys the branch's latest commit on every push and gets a unique URL. Its shape comes from app.json, which sets add-ons (with an ephemeral plan where the provider offers one), environment variables and a postdeploy script that runs once to seed data. Merging or closing the pull request destroys the review app, and an optional pr-predestroy script runs while it is being destroyed to clean up anything postdeploy set up outside the app.

Heroku review app pieceWhat it did
Pipeline and GitHub linkCreated and updated the app per pull request
app.json add-onsProvisioned a throwaway database and cache
postdeploySeeded test data once, on creation
Release phaseRan migrations on every push
Review app config varsHeld secrets that did not belong in app.json
Closing the pull requestDestroyed the app and its add-ons

Heroku bills review app dynos and add-ons like any other app, pro-rated to the second, so leaving one open costs money only while it exists.

What does a replacement on AWS need?

A hand-built version needs a CI workflow that runs when a pull request opens, and it has to do five things in the right order: build and push an image, create or update an ECS service with its own task definition, give it a database, put a listener rule or hostname in front of it, and post the URL on the pull request. A second workflow, triggered by the pull request closing, has to delete all of it, and a scheduled cleanup has to catch the ones that failed to delete, since an orphaned RDS instance is the expensive way to find out the cleanup step broke.

The database is the hard part. A new RDS instance takes several minutes to become available, so teams either share one instance with a schema or database per pull request, which means writing the create and drop logic, or use a database that supports branching. Secrets need the same treatment as in production, with an execution role that can read them, and the shared pieces (VPC, cluster, load balancer) need to stay out of the per-pull-request lifecycle so that deleting one preview never touches another.

How do preview environments work with Encore?

Encore brings infrastructure from code, and with GitHub connected, every pull request gets its own preview environment without a workflow to maintain. Per the preview environments docs, the environment is named after the pull request (pr:72), has a URL such as https://pr72-$APP_ID.encr.app, and is removed when the pull request closes. Preview environments run on Encore's managed hosting by default, while staging and production run in your own AWS account.

Application code passes through Encore and infrastructure guardrails to resources provisioned in your own AWS or GCP account.
Get started
brew install encoredev/tap/encore &&
encore app create
Copy

Run in your terminal to get started locally.

The database, topic or bucket a pull request needs comes from the same code as production, so there is no app.json to keep in sync. A small invitations service shows the pieces that Heroku configured separately:

// invites/invites.ts import { api, APIError } from "encore.dev/api"; import { appMeta } from "encore.dev"; import { secret } from "encore.dev/config"; import { SQLDatabase } from "encore.dev/storage/sqldb"; // Migrations run on every deploy, the job Heroku's release phase did. const db = new SQLDatabase("invites", { migrations: "./migrations" }); // Was a review app config var set in the pipeline settings. const resendKey = secret("ResendApiKey"); interface InviteRequest { email: string; } // Only signed-in team members can send invites; add a per-user rate limit as well. export const invite = api( { expose: true, auth: true, method: "POST", path: "/invites" }, async ({ email }: InviteRequest): Promise<{ id: number; sent: boolean }> => { if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)) throw APIError.invalidArgument("invalid email"); const row = await db.queryRow<{ id: number }>` INSERT INTO invites (email) VALUES (${email.toLowerCase()}) ON CONFLICT (email) DO UPDATE SET email = EXCLUDED.email RETURNING id`; // Pull request environments never email real people. if (appMeta().environment.type === "ephemeral") return { id: row!.id, sent: false }; const resp = await fetch("https://api.resend.com/emails", { method: "POST", headers: { Authorization: `Bearer ${resendKey()}`, "Content-Type": "application/json" }, body: JSON.stringify({ from: "team@example.com", to: [email], subject: "You have been invited", text: "Join the team: https://app.example.com/join", }), }); return { id: row!.id, sent: resp.ok }; }, );
-- invites/migrations/1_init.up.sql CREATE TABLE invites ( id BIGSERIAL PRIMARY KEY, email TEXT NOT NULL UNIQUE, created_at TIMESTAMPTZ NOT NULL DEFAULT now() );

The appMeta().environment.type check is the replacement for per-review-app environment variables, and an ephemeral type is what preview environments report, per the metadata docs. Secrets are set per environment type, so encore secret set --type dev,preview,local ResendApiKey covers every pull request at once, as described in the secrets docs.

For test data, Encore can seed each preview database from another environment. In the app settings under Preview Environments you choose which environment's database to copy, such as staging, and each new preview starts from a copy of it using Neon database branching, which is the default for Encore-hosted environments. Heroku's docs recommend seeding instead of copying production data, and the same advice applies to the environment you choose here.

The frontend change is a one-line change to the API base URL, and encore gen client --env=pr:72 --lang=typescript my-app generates a typed client for that branch's API. To deploy staging and production to AWS, connect your account as described in Connect your cloud account and push with git push encore.

A coding agent opening a pull request gets a running copy of its change at a URL it can test against, so it can check its own work before a person reviews it.

Best fit: Teams leaving Heroku for AWS that want a running copy of every pull request with its own database and URL, and no create-and-destroy pipeline to maintain.

What should you check before closing the Heroku pipeline?

Open the last few pull requests and compare what the review app showed with what the preview environment shows, paying attention to anything the postdeploy script created by hand, such as an admin user or sample records. Move those into a migration or a seed endpoint that is disabled in production, and delete the pipeline only when a pull request has gone through the new flow from open to merge.

Frequently asked questions

What replaces Heroku review apps on AWS?

AWS has no built-in equivalent, so teams build one with a CI job per pull request that creates an ECS service, a database and a URL, and destroys them on merge. A platform that provisions a preview environment per pull request does the same job without that pipeline.

How do I get test data into a preview environment?

Heroku runs the postdeploy script from app.json once when the review app is created, usually to seed the database. A preview environment can start with a copy of the database from another environment such as staging, selected in the app settings, and migrations run on every deploy.

Do preview environments run in my own AWS account?

No. With Encore, preview environments run on Encore's managed hosting by default, which keeps them quick to create and cheap to leave open, and your staging and production environments run in your own AWS account. Closing the pull request removes the preview environment.

How does the frontend point at a preview backend?

Each preview environment is named after its pull request, for example pr:72, and has a URL of the form https://pr72-APP_ID.encr.app. Generating the API client with encore gen client --env=pr:72 gives the frontend a typed client for that branch.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders