Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 10 min read How-to mediumAdept

Fullstack Serverless CI/CD in AWS Amplify Hosting with Postgres Database Branching

Each AWS Amplify Hosting app branch can get its own isolated Neon Postgres database branch, created automatically during CI/CD by a custom neon-ci.sh script that calls the Neon CLI and writes the branch connection string into DATABASE_URL in a .env file. The setup uses an amplify.yml build spec, an SSM SecureString for the Neon API key, IAM policy additions on the Amplify service role, and branch auto-detection. An optional cleanup-branches command deletes Neon branches that no longer have a matching Amplify branch. A Nuxt SSR server route then queries the branch database with the Neon serverless driver, and migrations with Drizzle or Prisma can run in the same pipeline.

Related posts

  • A database for every preview environment using Neon, GitHub Actions, and Vercel

    Neon mediumAdept

    Neon's copy-on-write branching can give every pull request its own production-like Postgres database, avoiding the bottlenecks of shared staging or shared preview databases. Branches are isolated, are created in about a second regardless of database size, and bill only for unique data. A GitHub Actions pipeline creates a Neon branch per PR, runs Prisma migrations against it, deploys a Vercel preview wired to that branch, and comments the URLs on the PR. Merging applies migrations to the primary branch, deploys to production and deletes the preview branch.

  • Branching Postgres databases with the Neon API

    Neon mediumAdept

    Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests. Two experimental GitHub Actions, neondatabase/create-branch-action and neondatabase/delete-branch-action, wrap the API. A sample pull-request workflow creates a branch from a parent branch, runs the test steps, then deletes the branch. The actions were beta at the time and still being hardened for production use.

  • Fullstack preview environments using Neon and Qovery

    Neon mediumAdept

    Each Qovery preview environment can get its own isolated Postgres database by using a Qovery lifecycle job that creates a copy-on-write Neon branch on the environment's Start event and deletes it on Delete. A Docker image bundles the Neon CLI and two shell scripts. create-branch.sh creates a branch named after QOVERY_ENVIRONMENT_NAME and writes direct and pooled connection strings to /qovery-output/qovery-output.json, so other services receive them as environment variables. delete-branch.sh looks up the branch ID through the Neon API and deletes it. This sidesteps the conflicts of a shared preview database and the slow provisioning, stale seed scripts and privacy issues of copying production data.

  • Neon Twin: Move Dev/Test/Staging to Neon, Keep Production on RDS

    Neon mediumAdept

    A Neon Twin is a nightly-synced copy of an RDS Postgres production database kept in Neon for dev, test and staging, so teams get instant provisioning, branching and scale-to-zero without migrating production. A scheduled GitHub Actions workflow installs Postgres, runs pg_dump in custom format against RDS, then pg_restore with --clean, --if-exists, --no-owner and --no-acl into a Neon main branch, with per-engineer branches created from it. Caveats include GitHub Actions' 6-hour job limit (use self-hosted runners for large databases), IP allowlisting problems with GitHub's changing runner IPs, and SSL certificate handling. Co-locating both databases in the same AWS region speeds up the job and cuts egress costs.

  • Make Yourself at Home with Neon Local

    Neon mediumAdept

    Neon Local is a Docker-based proxy that exposes a local Postgres endpoint for a Neon cloud database. By default it creates a fresh database branch when the container starts and deletes it when the container stops, giving isolated ephemeral environments for local development and CI without a local Postgres instance or environment drift. Configuration happens through environment variables: DRIVER selects the serverless or standard Postgres client, PARENT_BRANCH_ID picks the base branch, and DELETE_BRANCH=false keeps the branch between runs. Example docker-compose and docker run setups show how to point the Neon serverless driver at the proxy. Named branches and an offline dump/restore mode are planned.

The quest for software engineering knowledge.

Look:
Layout: