failoverDBCluster method

Future<FailoverDBClusterResult> failoverDBCluster({
  1. required String dBClusterIdentifier,
  2. String? targetDBInstanceIdentifier,
})

Forces a failover for a DB cluster.

A failover for a DB cluster promotes one of the Aurora Replicas (read-only instances) in the DB cluster to be the primary instance (the cluster writer).

Amazon Aurora will automatically fail over to an Aurora Replica, if one exists, when the primary instance fails. You can force a failover when you want to simulate a failure of a primary instance for testing. Because each instance in a DB cluster has its own endpoint address, you will need to clean up and re-establish any existing connections that use those endpoint addresses when the failover is complete.

For more information on Amazon Aurora, see What Is Amazon Aurora? in the Amazon Aurora User Guide.

May throw DBClusterNotFoundFault. May throw InvalidDBClusterStateFault. May throw InvalidDBInstanceStateFault.

Parameter dBClusterIdentifier : A DB cluster identifier to force a failover for. This parameter isn't case-sensitive.

Constraints:

  • Must match the identifier of an existing DBCluster.

Parameter targetDBInstanceIdentifier : The name of the instance to promote to the primary instance.

You must specify the instance identifier for an Aurora Replica in the DB cluster. For example, mydbcluster-replica1.

Implementation

Future<FailoverDBClusterResult> failoverDBCluster({
  required String dBClusterIdentifier,
  String? targetDBInstanceIdentifier,
}) async {
  ArgumentError.checkNotNull(dBClusterIdentifier, 'dBClusterIdentifier');
  final $request = <String, dynamic>{};
  $request['DBClusterIdentifier'] = dBClusterIdentifier;
  targetDBInstanceIdentifier
      ?.also((arg) => $request['TargetDBInstanceIdentifier'] = arg);
  final $result = await _protocol.send(
    $request,
    action: 'FailoverDBCluster',
    version: '2014-10-31',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['FailoverDBClusterMessage'],
    shapes: shapes,
    resultWrapper: 'FailoverDBClusterResult',
  );
  return FailoverDBClusterResult.fromXml($result);
}