Controlling access to database branches with IAM
You can use AWS Identity and Access Management (IAM) to control who can create, view, and delete database branches, and to control which branches a developer or AI agent can connect to. A common approach is to give each developer or agent access only to the branches they own. In this approach, each branch is tagged with a branch-owner tag whose value is the identity that created the branch, and the policy allows branch management and connection only when that tag matches the calling identity.
The following example IAM identity policy grants permission to create, view, and delete branches, to tag branches, and to connect to branches by using IAM database authentication. It uses a branch-owner tag set to the principal's unique identifier (${aws:userid}) so that each principal can manage and connect to only the branches they own.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["rds:CreateBranch", "rds:DeleteBranch", "rds:DescribeBranches"], "Resource": "arn:aws:rds:*:123456789012:cluster:*" }, { "Effect": "Allow", "Action": "rds:CreateBranch", "Resource": "arn:aws:rds:*:123456789012:branch:*", "Condition": { "StringEquals": { "aws:RequestTag/branch-owner": "${aws:userid}", "aws:ResourceTag/branch-owner": "${aws:userid}" } } }, { "Effect": "Allow", "Action": "rds:DescribeBranches", "Resource": "arn:aws:rds:*:123456789012:branch:*" }, { "Effect": "Allow", "Action": ["rds:DeleteBranch", "rds:AddTagsToResource", "rds:RemoveTagsFromResource", "rds:ListTagsForResource"], "Resource": "arn:aws:rds:*:123456789012:branch:*", "Condition": { "StringEquals": { "aws:ResourceTag/branch-owner": "${aws:userid}" } } }, { "Effect": "Allow", "Action": "rds:AddTagsToResource", "Resource": "arn:aws:rds:*:123456789012:branch:*", "Condition": { "StringEquals": { "aws:RequestTag/branch-owner": "${aws:userid}" } } }, { "Effect": "Deny", "Action": "rds:AddTagsToResource", "Resource": "arn:aws:rds:*:123456789012:branch:*", "Condition": { "ForAnyValue:StringEquals": { "aws:TagKeys": "branch-owner" }, "StringNotEquals": { "aws:RequestTag/branch-owner": "${aws:userid}" } } }, { "Effect": "Deny", "Action": "rds:AddTagsToResource", "Resource": "arn:aws:rds:*:123456789012:branch:*", "Condition": { "ForAnyValue:StringEquals": { "aws:TagKeys": "branch-owner" }, "StringNotEquals": { "aws:ResourceTag/branch-owner": "${aws:userid}" }, "Null": { "aws:ResourceTag/branch-owner": "false" } } }, { "Effect": "Deny", "Action": "rds:RemoveTagsFromResource", "Resource": "arn:aws:rds:*:123456789012:branch:*", "Condition": { "ForAnyValue:StringEquals": { "aws:TagKeys": "branch-owner" } } }, { "Effect": "Allow", "Action": "rds-db:connect", "Resource": "arn:aws:rds-db:*:123456789012:dbuser:br-*/*", "Condition": { "StringEquals": { "aws:ResourceTag/branch-owner": "${aws:userid}" } } } ] }
The policy includes the following permissions:
-
Allows creating, deleting, and describing branches on any cluster in the account.
-
Allows creating a branch only when the request tags the new branch with a
branch-ownertag set to the calling identity. When the branch is created from an existing branch, the source branch must also be owned by the calling identity. -
Allows describing branches. No tag condition is applied, because the describe operation lists branches that don't carry an owner tag at the cluster level.
-
Allows deleting, tagging, untagging, and listing tags only on branches that the calling identity owns (branches whose
branch-ownertag matches the identity). -
Allows adding the
branch-ownertag when a branch is created. -
Denies setting the
branch-ownertag to any value other than the calling identity. -
Denies claiming a branch that already has a different identity's
branch-ownertag. -
Denies removing the
branch-ownertag. -
Allows IAM database authentication (
rds-db:connect) only to branch database users (user names that begin withbr-) on branches that the calling identity owns.