

# Aurora data groups reference

This reference lists the AWS CLI commands, SQL statements, status values, events, and errors for data groups. The topic for each data group task also includes the commands for that task.

**Topics**
+ [AWS CLI commands and Amazon RDS API operations for data groups](#dg-ref-cli)
+ [SQL for data groups](#dg-ref-sql)
+ [Data group status values reference](#dg-ref-status)
+ [Data group events](#dg-ref-events)
+ [Data group errors](#dg-ref-errors)

## AWS CLI commands and Amazon RDS API operations for data groups
<a name="dg-ref-cli"></a>

The following table lists the AWS CLI commands and API operations for data groups.


**Data group commands**  

| AWS CLI command | API operation | What it does | 
| --- | --- | --- | 
| `create-data-group` | `CreateDataGroup` | Creates an empty data group. Takes `--db-cluster-identifier` and `--data-group-name`, and optionally `--kms-key-id`, `--additional-encryption-context`, and `--tags`. | 
| `describe-data-groups` | `DescribeDataGroups` | Describes one data group (`--data-group-identifier`) or the data groups in a DB cluster (`--db-cluster-identifier`). You can use both options together. | 
| `modify-data-group` | `ModifyDataGroup` | Turns on, renames, or turns off the data group endpoint. For more information, see [Data group endpoints](aurora-data-groups-endpoints.md). | 
| `move-data-group` | `MoveDataGroup` | Runs one move step. `--move-operation` is `prepare-move`, `execute-move`, or `cancel-move`. Prepare and execute also take `--target-db-cluster-identifier`. | 
| `delete-data-group` | `DeleteDataGroup` | Deletes a data group. | 
| `describe-data-group-restore-windows` | `DescribeDataGroupRestoreWindows` | Lists the times to which you can restore a data group. | 
| `describe-db-cluster-snapshot-data-groups` | `DescribeDBClusterSnapshotDataGroups` | Lists the data groups in a snapshot, or the snapshots that hold a data group. | 

Existing commands also have data group options and fields:
+ `restore-db-cluster-from-snapshot` and `restore-db-cluster-to-point-in-time` – `--data-group-restore-configurations` chooses the data groups to restore.
+ `describe-db-engine-versions` – `SupportsDataGroups` shows whether a version supports data groups.
+ `describe-db-cluster-snapshots` and `describe-db-cluster-automated-backups` – `CustomDataGroupPresent` shows whether the backup holds data groups that you created.
+ `describe-events` – `--source-type data-group` lists data group events.

Data group operations return a `DataGroup` object with the following fields: `DBClusterIdentifier`, `TargetDBClusterIdentifier`, `DataGroupName`, `DataGroupIdentifier`, `DataGroupArn`, `KMSKeyId`, `AdditionalEncryptionContext`, `StorageEncryptionType`, `Status`, `Endpoint`, `ReaderEndpoint`, `HostedZoneId`, `Tags`, and `CreateTime`. The response doesn't include fields that have no value. For example, it doesn't include `KMSKeyId` when the data group uses an AWS owned key, and it doesn't include the endpoint fields when the data group doesn't have a data group endpoint.

## SQL for data groups
<a name="dg-ref-sql"></a>

The following list shows the SQL for each data group task. Run these statements on the writer DB instance.

What a data group holds  
Databases. A data group shows as a tablespace with the same name.

Create a database in a data group  

```SQL
CREATE DATABASE {{db}} TABLESPACE {{dg}};
```
Or set the data group for the session first:  

```SQL
SET aurora_datagroup = '{{dg}}';
CREATE DATABASE {{db}};
RESET aurora_datagroup;
```

List data groups  

```SQL
SELECT * FROM pg_catalog.aurora_datagroups;
```

See which data group a database is in  
Join `pg_database` and `pg_tablespace` on `dattablespace`.

Map a role  

```SQL
SELECT * FROM aurora_datagroup_add_role_access('{{dg}}', '{{type}}', '{{role}}');
```

List mappings  

```SQL
SELECT * FROM aurora_datagroup_list_role_access();
```

Remove a mapping  

```SQL
SELECT * FROM aurora_datagroup_remove_role_access('{{dg}}', '{{role}}');
```

Find principals that block a move  
Prepare reports them in its error.

Start, switch over, or cancel a data group migration  

```SQL
SELECT aurora_start_data_group_migration('{{database}}', '{{dg}}');
SELECT aurora_switchover_data_group_migration('{{database}}');
SELECT aurora_cancel_data_group_migration('{{database}}');
```

Monitor a data group migration  

```SQL
SELECT * FROM information_schema.aurora_data_group_migration_status;
```

## Data group status values reference
<a name="dg-ref-status"></a>

The following table lists the data group status values in the Amazon RDS API and the console, and the operations that each one allows.


**Data group status values**  

| API value | Console label | Operations you can start | 
| --- | --- | --- | 
| `creating` | Creating | None | 
| `create-failed` | Create failed | Delete | 
| `active` | Active | Prepare a move, change the data group endpoint, delete (if empty) | 
| `modifying` | Modifying | None | 
| `preparing-for-move` | Preparing for move | Cancel the move | 
| `ready-to-move` | Ready to move | Execute the move, cancel the move | 
| `move-in-progress` | Move in progress | None | 
| `cancelling-move` | Cancelling move | None | 
| `restoring` | Restoring | None | 
| `inaccessible-encryption-credentials` | Inaccessible encryption credentials | Delete | 
| `deleting` | Deleting | None | 

For what each status means, see [Data group status values](aurora-data-groups-viewing.md#dg-status).

Most status changes finish within minutes. If a data group stays in `creating`, `preparing-for-move`, or `cancelling-move` for more than an hour, and the data group events show no reason, contact AWS Support. You can't delete a data group in `creating`, and you can't cancel a `cancelling-move`. If a data group stays in `preparing-for-move`, check for the conditions in [Before you move a data group](aurora-data-groups-moving.md#dg-move-before), such as an open prepared transaction. Then cancel the move with `cancel-move`.

## Data group events
<a name="dg-ref-events"></a>

The following table lists the Amazon RDS events for data groups. The source type is `data-group`. Messages that name a DB cluster use its identifier.


**Data group events**  

| Event ID | Category | Message | 
| --- | --- | --- | 
| RDS-EVENT-0515 | creation | Data group created | 
| RDS-EVENT-0530 | failure | Data group failed to create due to: {{reason}} | 
| RDS-EVENT-0531 | notification | Started data group prepare-move from {{source}} to {{target}} | 
| RDS-EVENT-0532 | notification | Data group ready for move (prepare complete) | 
| RDS-EVENT-0533 | notification | Data group move complete - execute done | 
| RDS-EVENT-0534 | failure | The message gives the reason the move failed. For example, a database with the same name already exists on the target DB cluster, or Amazon RDS can't access the data group's KMS key. | 
| RDS-EVENT-0535 | notification | Data group prepare-move from {{source}} to {{target}} was cancelled | 
| RDS-EVENT-0536 | deletion | Data group deleted | 
| RDS-EVENT-0537 | failure | Data group not empty and cannot be deleted | 
| RDS-EVENT-0538 | failure | Amazon RDS is unable to access the KMS encryption key for data group {{name}}. This is likely due to the key being disabled or Amazon RDS being unable to access it. This data group will be placed into an inaccessible state. | 

## Data group errors
<a name="dg-ref-errors"></a>

The following table lists the errors that data group operations can return, with their common causes and the actions to resolve them.


**Data group errors**  

| Error | Cause | Action | 
| --- | --- | --- | 
| `DataGroupNameInUseFault` | The name is already in use. `create-data-group` returns this error when a data group with the name is already on the DB cluster. `move-data-group` returns it when the name is in use on the target DB cluster, for a data group or for a database in the data group. | Choose another name, rename the conflicting database, or move to a DB cluster where the name is free. | 
| `DataGroupQuotaExceededFault` | The DB cluster has reached its data group quota, 100 data groups at preview. For a move, this applies to the target DB cluster. | Delete data groups that you don't need, or use another DB cluster. | 
| `DataGroupNotFoundFault` | The identifier is wrong, or the data group was deleted. | Use the `dg-` identifier or ARN from `create-data-group` or `describe-data-groups`. | 
| `InvalidParameterValue` | A value has the wrong format. For example, a data group name, or the `uuid` from the engine's SQL view, in place of the data group identifier. | Read the error message. For a data group, use the `dg-` identifier or ARN. | 
| `InvalidDataGroupStateFault` | The status doesn't allow the operation, or another operation is running on the data group. For example, you ran `execute-move` before `ready-to-move`. | Check the status, then run an operation that the status allows. For the allowed operations, see [Data group status values reference](#dg-ref-status). | 
| `InvalidDBClusterStateFault` | The source or target DB cluster isn't available, or doesn't meet a data group requirement such as Aurora I/O-Optimized storage or a writer DB instance. | Read the error message. Wait until the DB cluster is available, or fix the requirement that it names. | 
| `DBClusterNotFoundFault` | The DB cluster identifier is wrong. | Check the identifier and the AWS Region. | 
| `KMSKeyNotAccessibleFault` | The KMS key doesn't exist, isn't enabled, or you don't have permission to use it. | Fix the key policy or grants, or enable the key. | 
| `DataGroupRestoreWindowNotFoundFault` | No restore window matches the request. | Check the data group identifier, or the backup ARN and time. | 
| `DBClusterSnapshotDataGroupNotFoundFault` | The snapshot doesn't hold the data group. | Check the snapshot and data group identifiers. | 

When a move fails, the error message describes the problem. Common causes include the following:
+ A name that's already in use on the target DB cluster.
+ A parameter value that differs between the source and target DB clusters. For example, a parameter mismatch returns a message such as `Cannot move data group: parameter 'time_zone' must have the same value on source and target clusters`.
+ A target DB cluster that doesn't use Aurora I/O-Optimized storage.