Ephemeral environment

A temporary full stack created for one branch or pull request, then torn down after review so changes can be tested in isolation.

a full test stack for every pull requesttemporary environment per branchspin up the app for this PRthrowaway staging sitepreview with its own databasegive this pull request its own database toodestroy the test stack after mergeephemral environment

What it is

An ephemeral environment is a short-lived copy of the application stack created for a branch or pull request and destroyed when that work closes. Unlike a frontend-only preview URL, it can include its own API, database, queue, and configuration, giving one change an isolated place to run end to end.

Reach for one when several branches compete for a shared staging server, or when reviewers need to exercise migrations and backend changes before merge. Infrastructure as code makes the lifecycle repeatable: create on pull request open, update on each push, and destroy on close. Heroku Review Apps named this pattern for most people; a Terraform workspace or a Kubernetes namespace per pull request is the same shape built by hand.

Gotcha: temporary infrastructure becomes permanent billing when cleanup fails. Use a unique name and data store per pull request, attach an expiry time, run a scheduled janitor, and seed only synthetic data. Forked pull requests also need special care because provisioning credentials must never be exposed to code an outsider controls.

Ask AI for it

Create a per-pull-request environment with GitHub Actions and Terraform. On trusted pull_request opened, synchronize, and reopened events, create a Terraform workspace with the pr- prefix followed by github.event.number, then provision an isolated app, database, and synthetic seed data, then comment the HTTPS URL on the pull request. On pull_request closed, run terraform destroy and delete the workspace. Tag every resource with the pull request number and an expires_at timestamp, add a nightly cleanup workflow for expired resources, and never give provisioning credentials to forked code.

You might have meant

preview deploymentstaging environmentinfrastructure as codeenvironment variablesdeployment