How the new database branching preview gives AI coding agents and pull requests an isolated, copy-on-write copy of production data, and how to lock it down with TTLs, tags and IAM
The problem: code moves at agent speed, the database does not
AI coding agents are now good at writing migrations. They add a column, backfill it, create an index and update the ORM model in one pull request. The weak point is not writing the change. It is testing it against data that looks like production.
Most teams still have one shared staging database. Agents and developers queue for it, step on each other's schema changes, or test against a small seed dataset that hides the real problems: a slow index build on a large table, a NOT NULL constraint that fails on old rows, or a query plan that changes once real data volumes are present.
On 2 December 2026 AWS announced a preview of database branching for Amazon Aurora PostgreSQL. The idea is simple: every developer, agent and pull request can get its own isolated, writable branch of the production database, test the migration there, and throw the branch away. This article walks through how it works, a hands-on CLI and IAM setup based on the official docs, and the trade-offs to consider before you wire it into a CI pipeline or an agent loop.
What a branch actually is
The Aurora User Guide defines a branch as an isolated, queryable, copy-on-write version of your cluster's data. A few properties matter for architecture:
- Copy-on-write storage - a branch starts by sharing the parent cluster's data pages and stores only what changes on the branch, so Aurora does not physically copy the data when you create it.
- Its own serverless compute - every branch runs on Aurora Serverless, even if the parent is provisioned, and scales to zero when idle. Compute ranges from 0 ACU up to a configurable maximum (default 16, up to 64).
- Its own endpoint - each branch gets a read/write endpoint that inherits the parent's VPC and security groups.
- Inherited security - encryption at rest and in transit, database users and roles, and Aurora dynamic data masking policies all carry over from the parent.
- Mandatory TTL - every branch has a time-to-live between 1 hour and 90 days, and Aurora deletes it when the TTL expires.
- One level of nesting - you can branch from a branch, but only one child level deep.
The preview supports Aurora PostgreSQL 17 and higher in US East (Ohio), Europe (Frankfurt) and Asia Pacific (Mumbai). You can manage branches from the console, AWS CLI, SDKs and the AWS MCP Server, which is what makes it interesting for agents.
Reference architecture: one branch per pull request
The pattern AWS describes in the docs is a branch per pull request or per agent task. Here is how I would lay it out:
The key design choice is that the branch is disposable. If the migration fails, nothing needs cleaning up in a shared environment: you delete the branch, or let the TTL do it. Only a migration that has passed against production-shaped data goes on to the real cluster, still through your normal migration tool and approval process.
Hands-on: create, use and delete a branch
The commands below follow the AWS CLI reference for create-branch, describe-branches and delete-branch. The feature is in preview, so treat these as illustrative and check the current CLI reference before using them. Use a non-production cluster while you experiment.
1. Create a branch with a short TTL and an owner tag
export AWS_REGION=eu-central-1
CLUSTER=orders-aurora-pg17
BRANCH=pr-1423-add-order-status
aws rds create-branch \
--branch-name "$BRANCH" \
--source-db-cluster-identifier "$CLUSTER" \
--ttl-seconds 14400 \
--scaling-configuration MaxCapacity=8,SecondsUntilAutoPause=300 \
--tags Key=branch-owner,Value="$(aws sts get-caller-identity --query UserId --output text)"
A few notes from the reference:
- Branch names are 1 to 63 alphanumeric characters or hyphens and must start with a letter, so a
pr-<number>-<slug>naming scheme works well. -
--ttl-secondshere is 4 hours. The TTL range is 1 hour to 90 days. -
MaxCapacitycaps the branch's ACUs, andSecondsUntilAutoPause(300 to 86,400 seconds) controls how long it can sit idle before it pauses. - The call returns the branch with status
creating.
2. Wait for it and get the endpoint
until [ "$(aws rds describe-branches \
--db-cluster-identifier "$CLUSTER" --branch-name "$BRANCH" \
--query 'Branches[0].Status' --output text)" = "available" ]; do
sleep 15
done
read ENDPOINT PORT <<<"$(aws rds describe-branches \
--db-cluster-identifier "$CLUSTER" --branch-name "$BRANCH" \
--query 'Branches[0].[Endpoint,Port]' --output text)"
Besides available, watch for the failure states the API documents, such as failed, insufficient-capacity and incompatible-network, and fail the pipeline quickly if you see one.
3. Connect with IAM authentication and run the migration
Because the branch inherits the parent's database users, an IAM-enabled database user on the parent can connect to the branch with a short-lived token instead of a stored password:
TOKEN=$(aws rds generate-db-auth-token \
--hostname "$ENDPOINT" --port "$PORT" --username ci_migrator)
PGPASSWORD="$TOKEN" psql "host=$ENDPOINT port=$PORT dbname=orders user=ci_migrator sslmode=verify-full sslrootcert=global-bundle.pem" \
-f migrations/V42__add_order_status.sql
# then run the application test suite against the branch
DATABASE_URL="postgresql://ci_migrator@$ENDPOINT:$PORT/orders" npm test
This step is illustrative: confirm that IAM database authentication is enabled on the parent and that your CI role has rds-db:connect on the branch, as shown in the next section.
4. Delete it when the PR closes
aws rds delete-branch --db-cluster-identifier "$CLUSTER" --branch-name "$BRANCH"
The TTL is your safety net, but explicit deletion on PR close keeps you well under the quota of 50 branches per cluster and 2,000 per account.
Locking it down: each agent only sees its own branches
This is where branching becomes an agent-safety feature rather than just a convenience. The Aurora docs include an IAM policy pattern built on a branch-owner tag set to the caller's ${aws:userid}. In short, the policy:
- allows
rds:CreateBranchonly when the request tags the new branch with the caller's own ID - allows
rds:DeleteBranchand tag changes only on branches the caller owns - denies anyone from changing or removing someone else's
branch-ownertag - allows
rds-db:connectonly to branch database users (dbuser:br-*/*) on branches tagged with the caller's ID
A trimmed extract of the connect statement looks like this (see the docs for the full policy, including the deny statements that stop tag tampering):
{
"Effect": "Allow",
"Action": "rds-db:connect",
"Resource": "arn:aws:rds-db:*:123456789012:dbuser:br-*/*",
"Condition": {
"StringEquals": { "aws:ResourceTag/branch-owner": "${aws:userid}" }
}
}
Combine this with the parent's existing controls. Since branches inherit dynamic data masking policies, an agent working on a branch sees masked values for columns you already protect, which is a much better default than restoring a snapshot into an unmanaged dev account.
Trade-offs, cost and security notes
- It is a preview. The docs say behaviour, defaults and limits may change before GA, and you cannot change a branch's settings after creation during the preview. Do not build anything production-critical on it yet.
- Not a production replica. Each branch is a single compute instance with no Multi-AZ failover, no automated backups and no SLA. It is for development and testing only.
- Performance testing has limits. The branch runs on serverless compute with its own capacity cap, and it inherits the parent's parameters. It will tell you whether a migration works on real data shapes, but timing results will not exactly match your provisioned production writer.
-
Cost model. AWS states there is no extra charge for branching itself. You pay for the serverless compute the branch uses and for the data changed within the branch, at existing Aurora serverless rates. Keep
MaxCapacitymodest, keep TTLs short and let idle branches pause. - Production data is still production data. Inherited masking and IAM help, but think about which columns are masked, who can create branches from the production cluster, and whether some teams should branch from a masked or anonymised copy instead.
- Network reach. The branch endpoint inherits the parent's VPC and security groups, so your CI runners or agent sandboxes need the same network path to the cluster as any other client.
- Region availability. Only three Regions in the preview, which may rule it out for some data residency requirements today.
Conclusion
Database branching closes a gap that has grown quickly as coding agents write more of our migrations: we could test code in isolation per pull request, but the database stayed shared and slow to copy. With copy-on-write branches, a mandatory TTL, inherited masking and tag-based IAM, Aurora PostgreSQL now gives each agent or pull request its own short-lived, production-shaped database, scoped to the identity that created it.
My suggestion is to start small: a non-production Aurora PostgreSQL 17 cluster in one of the preview Regions, a CI job that creates a branch per pull request with a 4-hour TTL, runs the migration and test suite, and deletes the branch on close. Once that works, add the branch-owner IAM pattern so agents can create their own branches without ever touching anyone else's.
References
- AWS What's New - Announcing database branching for Amazon Aurora PostgreSQL (Preview): https://aws.amazon.com/about-aws/whats-new/2026/12/aurora-postgresql-branching-preview/
- AWS News Blog - AWS helps agents do more with your data: https://aws.amazon.com/blogs/aws/aws-helps-agents-do-more-with-your-data/
- Amazon Aurora User Guide - Using database branches: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-branching.html
- Amazon Aurora User Guide - How database branches work: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-branching-how-it-works.html
- Amazon Aurora User Guide - Branch capabilities, limitations, and quotas: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-branching-limitations.html
- Amazon Aurora User Guide - Controlling access to database branches with IAM: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-branching-iam.html
- AWS CLI Command Reference - create-branch: https://docs.aws.amazon.com/cli/latest/reference/rds/create-branch.html
- AWS CLI Command Reference - describe-branches: https://docs.aws.amazon.com/cli/latest/reference/rds/describe-branches.html
- AWS CLI Command Reference - delete-branch: https://docs.aws.amazon.com/cli/latest/reference/rds/delete-branch.html

Top comments (0)