---
title: "Fullstack Serverless CI/CD in AWS Amplify Hosting with Postgres Database Branching"
description: "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."
url: "https://swe.quest/articles/fullstack-serverless-ci-cd-in-aws-amplify-hosting-with-postgres-database-5ab5e970ace5ba81"
canonical: "https://neon.com/blog/fullstack-serverless-ci-cd-in-aws-amplify-hosting-with-postgres-database-branching"
source: "Neon"
published: "2024-03-06"
difficulty: "medium"
kind: "How-to"
reading_minutes: 10
tags: ["ci-cd","postgres","serverless","cloud","deployment"]
---

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

A post on [Neon](https://swe.quest/sources/neon.md), published 2024-03-06, 10 min read, How-to. Original: [https://neon.com/blog/fullstack-serverless-ci-cd-in-aws-amplify-hosting-with-postgres-database-branching](https://neon.com/blog/fullstack-serverless-ci-cd-in-aws-amplify-hosting-with-postgres-database-branching)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)

## Prerequisites

- AWS IAM basics ([easy posts on Cloud platforms](https://swe.quest/tags/cloud.md?difficulty=easy))
- CI/CD pipelines ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))
- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- SSR frameworks like Nuxt or Next.js ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))

## Keywords

AWS Amplify Hosting, Neon, neonctl, Nuxt, AWS SSM Parameter Store, Neon Serverless Driver

## Related posts

- [A database for every preview environment using Neon, GitHub Actions, and Vercel](https://swe.quest/articles/a-database-for-every-preview-environment-using-neon-github-actions-and-vercel-dd5fe24cba2d12b5.md): Neon · 2023-04-14 · Medium · 14 min read · PostgreSQL, CI/CD, Deployment, Schema migrations
  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.
- [Branching Postgres databases with the Neon API](https://swe.quest/articles/branching-postgres-databases-with-the-neon-api-3faf0de941bc811a.md): Neon · 2022-12-07 · Medium · 3 min read · PostgreSQL, CI/CD, Testing
  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.
- [Fullstack preview environments using Neon and Qovery](https://swe.quest/articles/fullstack-preview-environments-using-neon-and-qovery-5ddb9f5e7c2f931c.md): Neon · 2023-08-11 · Medium · 8 min read · PostgreSQL, CI/CD, Deployment, Serverless
  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.
- [Neon Twin: Move Dev/Test/Staging to Neon, Keep Production on RDS](https://swe.quest/articles/neon-twin-move-dev-test-staging-to-neon-keep-production-on-rds-a26cd19df36ac332.md): Neon · 2024-07-24 · Medium · 7 min read · PostgreSQL, CI/CD, Databases
  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.
- [Make Yourself at Home with Neon Local](https://swe.quest/articles/make-yourself-at-home-with-neon-local-be56a855dab1fc15.md): Neon · 2025-04-30 · Medium · 5 min read · PostgreSQL, Containers, Testing, Developer tools
  Neon Local is a Docker-based proxy that exposes a local Postgres endpoint for a Neon cloud database.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
