

# IAM and API permissions

You manage a database cluster group for Aurora through the Amazon RDS API. IAM policies control who can call each operation on the group resource, and database privileges control what a session can read and write after it connects. Each member cluster is also an Aurora DB cluster, so the usual Amazon RDS actions and condition keys apply to it. For how IAM works with Aurora, see [Identity and access management for Amazon Aurora](UsingWithRDS.IAM.md).

To create an AWS account and an IAM identity to manage the group, see [Setting up your environment for Amazon Aurora](CHAP_SettingUp_Aurora.md). Then give the identity the group actions that it needs, as described in the following sections.

## API operations for database cluster groups for Aurora
<a name="databaseclustergroups-iam-operations"></a>

The following table lists the API operations for database cluster groups for Aurora.


| API operation (AWS CLI command) | What it does | 
| --- | --- | 
| CreateDBClusterGroup (create-db-cluster-group) | Creates a group, with or without routing | 
| DescribeDBClusterGroups (describe-db-cluster-groups) | Describes groups, their members, and the routing endpoint | 
| ModifyDBClusterGroup (modify-db-cluster-group) | Changes group settings, routing, the routing endpoint, the engine version, and the administrative router user | 
| DeleteDBClusterGroup (delete-db-cluster-group) | Deletes a group | 
| AddDBClusterToDBClusterGroup (add-db-cluster-to-db-cluster-group) | Adds an existing DB cluster as a member cluster | 
| RemoveDBClusterFromDBClusterGroup (remove-db-cluster-from-db-cluster-group) | Removes a member cluster from the group | 
| CreateDBClusterGroupSnapshot, DescribeDBClusterGroupSnapshots, DeleteDBClusterGroupSnapshot | Create, list, and delete group snapshots | 
| DescribeDBClusterGroupAutomatedBackups, DescribeDBClusterGroupAutomatedBackupMembers, DeleteDBClusterGroupAutomatedBackup | List and delete the group's automated backups | 
| RestoreDBClusterGroupFromSnapshot, RestoreDBClusterGroupToPointInTime | Restore a whole group | 

Some existing Amazon RDS operations also take a group:
+ `CreateDBCluster` creates a cluster in a group.
+ `ModifyDBCluster` sets a member cluster's upgrade wave.
+ The tagging operations take the group's ARN.

**Note**  
To add a DB cluster to a group, your policy must allow `rds:AddDBClusterToDBClusterGroup`.

The describe operations return each resource's ARN: `DBClusterGroupArn`, `DBClusterGroupSnapshotArn`, and `DBClusterGroupAutomatedBackupArn`. Read an ARN from the describe output instead of composing it. A policy names a group by its `DBClusterGroupArn`, in the format `arn:aws:rds:{{region}}:{{account}}:cluster-group:{{resource-id}}`.

## Actions, resources, and condition keys
<a name="databaseclustergroups-iam-actions"></a>

The following table shows the resources that each group action authorizes against.


| Action | Authorized against | 
| --- | --- | 
| rds:CreateDBClusterGroup | \* (the group doesn't exist yet). Restrict creates with condition keys such as aws:RequestTag, rds:DeletionProtection, and rds:BackupRetentionPeriod. | 
| rds:DeleteDBClusterGroup, rds:ModifyDBClusterGroup | The group (cluster-group) | 
| rds:RemoveDBClusterFromDBClusterGroup | The group and the DB cluster (cluster). Your policy must allow both resources. | 
| rds:AddDBClusterToDBClusterGroup | The group and the DB cluster (cluster). Your policy must allow both resources. | 
| rds:DescribeDBClusterGroups | The group, or \* to list groups | 
| rds:AddTagsToResource, rds:RemoveTagsFromResource, rds:ListTagsForResource | The group, named by its group ARN | 

Adding a cluster to a group also authorizes against both the group and the DB cluster, so your policy must allow both. A `ModifyDBClusterGroup` call that changes the engine version also authorizes `rds:ModifyDBCluster` on each member cluster. `CreateDBClusterGroup` also needs `rds:AddTagsToResource` and an action for the group's automated backup (`cluster-group-auto-backup`). `DeleteDBClusterGroup` also needs `rds:DeleteDBClusterGroupAutomatedBackup` on the group's automated backup, unless you pass `--no-delete-automated-backups`.

**Note**  
Adding a cluster to a group uses `rds:AddDBClusterToDBClusterGroup`. Describing groups uses `rds:DescribeDBClusterGroups`. `CreateDBClusterGroup` and both group restores also need `rds:CreateDBClusterGroupAutomatedBackup` for the group's automated backup. This action has no API operation of its own.

`CreateDBClusterGroup` supports the `rds:BackupRetentionPeriod` and `rds:DeletionProtection` condition keys, and the standard AWS tag condition keys. Neither kind of group restore sets the `rds:DatabaseName` condition key. Before you write a policy that denies by action name, check the action list in the Amazon RDS API reference. A policy with an incomplete list can deny an operation that you meant to allow.

A policy for a group works like a policy for any other Amazon RDS resource. The IAM console lists the AWS managed policies in your account. For the managed policies for Amazon RDS, see [AWS managed policies for Amazon RDS](rds-security-iam-awsmanpol.md).

**Note**  
`AmazonRDSFullAccess` allows all actions for database cluster groups for Aurora, because it allows every Amazon RDS action. `AmazonRDSReadOnlyAccess` allows the group describe actions, such as `rds:DescribeDBClusterGroups`, and `rds:ListTagsForResource`. It doesn't allow actions that create or change a group.

## Authorization for operations that span many resources
<a name="databaseclustergroups-iam-many-resources"></a>

One group operation can create or change many resources. Amazon RDS checks every dependent resource before it creates any of them. A denial on one resource fails the whole operation, and Amazon RDS creates no resources. If a dependent resource fails the check, the call fails with an access denied error that names the denied action. For how to read events, see [Monitoring database cluster groups for Aurora](databaseclustergroups-monitoring.md).

For example, a group restore checks each member cluster restore against your policy before it creates any resource, using the member configuration that the backup recorded. IAM checks your conditions on each member cluster's DB subnet group and tags. A restore from a snapshot also sets the `rds:DatabaseEngine` and `rds:StorageEncrypted` condition keys for each member cluster. For the backup resource permissions, see [Backing up and restoring a database cluster group for Aurora](databaseclustergroups-backups.md).

**Note**  
For each member cluster, a point-in-time group restore checks `rds:RestoreDBClusterToPointInTime` on the group's automated backup, the new DB cluster, and its DB subnet group. A group restore from a snapshot checks `rds:RestoreDBClusterFromSnapshot` on the group snapshot, the new DB cluster, and its DB subnet group. If the new member cluster gets tags, both restores also check `rds:AddTagsToResource` on it. Both restores also check `rds:CreateDBClusterGroupAutomatedBackup` once for the new group. Amazon RDS doesn't check the source member cluster, its own snapshot, or `rds:CreateDBInstance`.

## IAM database authentication
<a name="databaseclustergroups-iam-db-auth"></a>

Router users sign in with a password. IAM database authentication for router users isn't available at preview. You can't create or change a router user to use IAM database authentication at the routing endpoint. A direct connection to a member cluster uses that cluster's own sign-in methods, including IAM database authentication if you turned it on for the cluster.

A `CREATE USER` or `ALTER USER` statement with `IDENTIFIED WITH AWSAuthenticationPlugin` fails with error 1396 (HY000) `Plugin 'AWSAuthenticationPlugin' is not a supported authentication plugin`.

```sql
-- Not supported at the routing endpoint at preview. Returns error 1396.
CREATE USER '{{APP_USER}}'@'%' IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS';
```

IAM database authentication isn't available for router users. To use IAM database authentication, connect directly to a member cluster. For how IAM database authentication works on a DB cluster, see [IAM database authentication ](UsingWithRDS.IAMDBAuth.md). For the authentication methods that router users support, see [Creating a router user](databaseclustergroups-router-users.md#databaseclustergroups-router-users-create).

## Protecting member clusters with IAM
<a name="databaseclustergroups-iam-member-clusters"></a>

A direct change to one member cluster, such as a parameter group change, applies only to that cluster. The group doesn't align its member clusters' settings. To limit these changes, give the member clusters a common tag, and then deny the Amazon RDS modify actions in an IAM policy with a condition on that tag. For examples, see [Identity-based policy examples for Amazon Aurora](security_iam_id-based-policy-examples.md).

AWS CloudTrail records the Amazon RDS API calls for the group and for its member clusters, including `CreateDBClusterGroup`, `ModifyDBClusterGroup`, `AddDBClusterToDBClusterGroup`, and `DeleteDBClusterGroup`. For more information, see [Monitoring Amazon Aurora API calls in AWS CloudTrail](logging-using-cloudtrail.md).

## Identity-based policy examples
<a name="databaseclustergroups-iam-policy-examples"></a>

The following policies allow and deny group actions. Replace the AWS Region, account ID, group resource ID, and tag key with your own values.

**Allow control of one group.** The following policy allows the group actions on one group. To also allow adding clusters and describing groups, add those actions, as described in [Actions, resources, and condition keys](#databaseclustergroups-iam-actions).

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ControlOfOneGroup",
      "Effect": "Allow",
      "Action": [
        "rds:DeleteDBClusterGroup",
        "rds:ModifyDBClusterGroup",
        "rds:RemoveDBClusterFromDBClusterGroup",
        "rds:AddTagsToResource",
        "rds:RemoveTagsFromResource",
        "rds:ListTagsForResource"
      ],
      "Resource": "arn:aws:rds:us-east-2:123456789012:cluster-group:{{RESOURCE_ID}}"
    }
  ]
}
```

**Allow adding one cluster to one group.** This action checks two resources, so the policy needs one statement for the group and one for the cluster. Name the cluster in the second statement. A wildcard there allows any cluster in the account.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowTheGroup",
      "Effect": "Allow",
      "Action": "rds:AddDBClusterToDBClusterGroup",
      "Resource": "arn:aws:rds:us-east-2:123456789012:cluster-group:{{RESOURCE_ID}}"
    },
    {
      "Sid": "AllowTheCluster",
      "Effect": "Allow",
      "Action": "rds:AddDBClusterToDBClusterGroup",
      "Resource": "arn:aws:rds:us-east-2:123456789012:cluster:{{CLUSTER_NAME}}"
    }
  ]
}
```

**Note**  
The example uses `rds:AddDBClusterToDBClusterGroup`, the action for adding a DB cluster to a group.

**Require deletion protection on every new group.** Deletion protection is off for a new group unless you turn it on. To turn it on, see [Changing group settings](databaseclustergroups-group-lifecycle.md#databaseclustergroups-group-lifecycle-modify). The following policy denies a create or restore request that sets deletion protection to `false`. Amazon RDS evaluates an omitted setting as `false`, so the policy also denies a request that leaves the setting out.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyWithoutDeletionProtection",
      "Effect": "Deny",
      "Action": [
        "rds:CreateDBClusterGroup",
        "rds:RestoreDBClusterGroupFromSnapshot",
        "rds:RestoreDBClusterGroupToPointInTime"
      ],
      "Resource": "*",
      "Condition": {
        "Bool": { "rds:DeletionProtection": "false" }
      }
    }
  ]
}
```

**Require a minimum backup retention period.** A create request that leaves out `BackupRetentionPeriod` keeps backups for 1 day, but IAM evaluates the `rds:BackupRetentionPeriod` key as 7 for that request. For a create request the key is never absent, so a `Null` condition on it never matches, and a condition that denies values less than 7 still allows the request, which keeps the 1-day backups. The following policy denies a value below 8, so it also denies a request that leaves the setting out. It also denies a request that passes 7, so IAM can't enforce a minimum of exactly 7 days. A group restore accepts `BackupRetentionPeriod` but doesn't set this key, so this policy can't limit the retention period of a restored group.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyShortBackupRetention",
      "Effect": "Deny",
      "Action": "rds:CreateDBClusterGroup",
      "Resource": "*",
      "Condition": {
        "NumericLessThan": { "rds:BackupRetentionPeriod": 8 }
      }
    }
  ]
}
```

**Require a tag on every new group.**

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "RequireCostCenterTag",
      "Effect": "Deny",
      "Action": "rds:CreateDBClusterGroup",
      "Resource": "*",
      "Condition": {
        "Null": { "aws:RequestTag/CostCenter": "true" }
      }
    }
  ]
}
```

**Troubleshooting access**

A permission problem belongs to one of two layers. IAM authorizes the Amazon RDS API calls on the group, and database privileges authorize the statements of a session after it connects. The following table covers the IAM layer.


| Symptom | Cause | What to do | 
| --- | --- | --- | 
| An operation on many resources fails with an access-denied error that names an action you didn't call directly | A dependent resource failed authorization, and the call fails with a synchronous access-denied error that names the denied action | Read the access-denied error, which names the denied action, instead of the Amazon RDS events | 
| A group restore fails, and no resource exists | Your policy denied one member cluster restore, and one denial fails the whole restore | Allow the actions that each member cluster restore needs, and run the restore again | 
| A connection opens, and a statement fails with a permission error | Database privileges, not IAM | See [Sign-in is refused](databaseclustergroups-ts-connections.md#databaseclustergroups-authentication-errors-in-detail) | 

For IAM errors that aren't specific to groups, see [Troubleshooting Amazon Aurora identity and access](security_iam_troubleshoot.md).