

# Getting started with database branches

Working with database branches involves two audiences. Administrators and data infrastructure engineers set up access and security controls once on the parent cluster. Developers and AI coding agents then create branches, connect to them, and delete them when the work is done.

## Set up access
<a name="aurora-branching-setup-access"></a>

As an administrator or data infrastructure engineer, you set up branch access on the parent cluster. Each branch inherits these settings, so you configure these controls one time on the parent.

1. On the parent cluster, add the branching IAM actions to the roles that your developers, agents, and pipelines already use. You can scope these actions to specific clusters or tags. The branching actions are `rds:CreateBranch`, `rds:DeleteBranch`, and `rds:DescribeBranches`. Roles that already have full Aurora access get the branching actions automatically. For more information about how IAM works with Aurora, see [Security in Amazon Aurora](UsingWithRDS.md). For an example policy that controls branch access, see [Controlling access to database branches with IAM](aurora-branching-iam.md).

1. Define the database users and roles that developers and agents use to connect to branches. Developers and agents can connect to a branch using IAM database authentication, which lets administrators control branch access through IAM policies. For more information, see [IAM database authentication ](UsingWithRDS.IAMDBAuth.md).

1. Configure Aurora dynamic data masking policies to control which data developers and agents can see in a branch. For more information, see [Using dynamic masking with Aurora PostgreSQL](AuroraPostgreSQL.Security.DynamicMasking.md).

## Create and connect to a branch
<a name="aurora-branching-create-connect"></a>

As a developer or AI coding agent, you create a branch from the parent cluster or from another branch. You can create a branch by using the AWS Management Console, the AWS CLI, or the AWS SDKs.

### Creating a branch
<a name="aurora-branching-create"></a>

You can create a branch from the parent cluster or from an existing branch.

#### Console
<a name="aurora-branching-create.console"></a>

**To create a branch**

1. Sign in to the AWS Management Console and open the Amazon RDS console at [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/).

1. Choose the AWS Region and the database cluster that you want to branch from.

1. Choose the **Branches** tab, and then choose **Create branch**.  
![The Branches tab on an Aurora cluster before any branches exist, showing a Create branch button.](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/images/aurora-branching-branches-tab-empty.png)

1. Review the pre-configured settings in the **Create branch** dialog. When you branch from the cluster, the **Branch from** dropdown is prepopulated with the cluster name.  
![The Create branch dialog when branching from a cluster, showing the Branch from source, minimum capacity of 0 ACU, maximum capacity, and Time to live (TTL).](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/images/aurora-branching-create-from-cluster.png)

1. You can also create a branch from an existing branch. When you do, **Branch from** is set to the branch name, and the **Time to live (TTL)** is capped by the source branch's remaining TTL.  
![The Create branch dialog when branching from an existing branch, where the Time to live (TTL) is capped by the source branch's remaining TTL.](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/images/aurora-branching-create-from-branch.png)

#### AWS CLI
<a name="aurora-branching-create.cli"></a>

To create a branch by using the AWS CLI, use the `create-branch` command. The following AWS CLI command creates a branch from a cluster with the minimum required options.

```shell
aws rds create-branch \
    --branch-name feature-auth-refactor \
    --source-db-cluster-identifier my-prod-cluster
```

The following example creates a branch from an existing branch and sets the TTL, the scaling configuration, and tags.

```shell
aws rds create-branch \
    --branch-name feature-auth-refactor \
    --source-db-cluster-identifier my-prod-cluster \
    --source-branch-name some-branch \
    --ttl-seconds 604800 \
    --scaling-configuration MaxCapacity=8,SecondsUntilAutoPause=300 \
    --tags Key=team,Value=backend
```

#### RDS API
<a name="aurora-branching-create.api"></a>

To create a branch programmatically, use your preferred AWS SDK to call the `CreateBranch` operation. You can create a branch from a cluster or from an existing branch. This operation requires the `rds:CreateBranch` IAM action.

### Viewing branches
<a name="aurora-branching-view"></a>

You can view the branches on a cluster and their current status.

#### Console
<a name="aurora-branching-view.console"></a>

After you create branches, the **Branches** tab lists the active branches with their **Status**, **Size**, **TTL**, and **Created at** values.

![The Branches tab listing active branches with their Status, Size, TTL, and Created at values.](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/images/aurora-branching-branches-tab.png)


Placeholder: step-by-step console instructions for viewing branches will be added here.

#### AWS CLI
<a name="aurora-branching-view.cli"></a>

To list branches, use the `describe-branches` command. You can list all branches, describe a single branch by its Amazon Resource Name (ARN), or filter branches by source cluster or branch name.

```shell
aws rds describe-branches

aws rds describe-branches \
    --branch-arn arn:aws:rds:us-east-1:123456789012:branch:cluster-ABCDEFGH/br-0a1b2c3d4e5f67890

aws rds describe-branches \
    --filters Name=source-db-cluster-identifier,Values=my-prod-cluster

aws rds describe-branches \
    --db-cluster-identifier my-prod-cluster \
    --branch-name feature-auth-refactor
```

#### RDS API
<a name="aurora-branching-view.api"></a>

To list branches and view their status programmatically, use your preferred AWS SDK to call the `DescribeBranches` operation. This operation requires the `rds:DescribeBranches` IAM action.

### Deleting a branch
<a name="aurora-branching-delete"></a>

When you finish with a branch, you can delete it. If you don't delete a branch, Aurora deletes it automatically when its TTL expires.

#### Console
<a name="aurora-branching-delete.console"></a>

**To delete a branch**

1. On the cluster's **Branches** tab, select the branch that you want to delete, and then choose **Delete**.

1. In the **Delete branch** dialog box, to confirm the deletion, enter **confirm** in the text box, and then choose **Delete**. Deleting a branch permanently deletes the branch and its data and can't be undone; the source cluster and its other branches aren't affected.  
![The Delete branch confirmation dialog, which asks you to type confirm to permanently delete the branch, and notes that the branch's data is deleted while the source cluster and other branches are not affected.](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/images/aurora-branching-delete-dialog.png)

#### AWS CLI
<a name="aurora-branching-delete.cli"></a>

To delete a branch when you finish with it, use the `delete-branch` command and specify the branch ARN. In the following example, replace {{branch-arn}} with the ARN of the branch that you want to delete.

```shell
aws rds delete-branch --branch-arn <branch-arn>
```

#### RDS API
<a name="aurora-branching-delete.api"></a>

To delete a branch programmatically, use your preferred AWS SDK to call the `DeleteBranch` operation. This operation requires the `rds:DeleteBranch` IAM action.

You can automate the branch lifecycle in your CI/CD pipelines. For example, a pipeline can create a branch when a pull request opens and delete the branch when the pull request closes, by using Amazon EventBridge with tools such as AWS CodePipeline and GitHub Actions.

**Important**  
To avoid ongoing charges for branches that you no longer need, delete them with the `delete-branch` command, or let Aurora delete them automatically when their TTL expires.