Skip to content

failover_global_cluster async

failover_global_cluster(
    *,
    config_overrides: Optional[AsyncDocDBClientConfig] = None,
    global_cluster_identifier: Optional[GlobalClusterIdentifier] = None,
    target_db_cluster_identifier: Optional[DBClusterIdentifier] = None,
    allow_data_loss: Optional[BooleanOptional] = None,
    switchover: Optional[BooleanOptional] = None,
) -> FailoverGlobalClusterResult

Promotes the specified secondary DB cluster to be the primary DB cluster in the global cluster when failing over a global cluster occurs.

Use this operation to respond to an unplanned event, such as a regional disaster in the primary region. Failing over can result in a loss of write transaction data that wasn't replicated to the chosen secondary before the failover event occurred. However, the recovery process that promotes a DB instance on the chosen seconday DB cluster to be the primary writer DB instance guarantees that the data is in a transactionally consistent state.

Parameters:

  • global_cluster_identifier (Optional[GlobalClusterIdentifier], default: None ) –

    The identifier of the Amazon DocumentDB global cluster to apply this operation. The identifier is the unique key assigned by the user when the cluster is created. In other words, it's the name of the global cluster.

    Constraints:

    • Must match the identifier of an existing global cluster.

    • Minimum length of 1. Maximum length of 255.

    Pattern: [A-Za-z][0-9A-Za-z-:._]*

  • target_db_cluster_identifier (Optional[DBClusterIdentifier], default: None ) –

    The identifier of the secondary Amazon DocumentDB cluster that you want to promote to the primary for the global cluster. Use the Amazon Resource Name (ARN) for the identifier so that Amazon DocumentDB can locate the cluster in its Amazon Web Services region.

    Constraints:

    • Must match the identifier of an existing secondary cluster.

    • Minimum length of 1. Maximum length of 255.

    Pattern: [A-Za-z][0-9A-Za-z-:._]*

  • allow_data_loss (Optional[BooleanOptional], default: None ) –

    Specifies whether to allow data loss for this global cluster operation. Allowing data loss triggers a global failover operation.

    If you don't specify AllowDataLoss, the global cluster operation defaults to a switchover.

    Constraints:

    • Can't be specified together with the Switchover parameter.

  • switchover (Optional[BooleanOptional], default: None ) –

    Specifies whether to switch over this global database cluster.

    Constraints:

    • Can't be specified together with the AllowDataLoss parameter.

Raises:

Source code in docs_src/capo_docdb/_services/async_doc_db.py
async def failover_global_cluster(
    self,
    *,
    config_overrides: Optional[AsyncDocDBClientConfig] = None,
    global_cluster_identifier: Optional[
        "capo_docdb.types.global_cluster_identifier.GlobalClusterIdentifier"
    ] = None,
    target_db_cluster_identifier: Optional[
        "capo_docdb.types.db_cluster_identifier.DBClusterIdentifier"
    ] = None,
    allow_data_loss: Optional[
        "capo_docdb.types.boolean_optional.BooleanOptional"
    ] = None,
    switchover: Optional[
        "capo_docdb.types.boolean_optional.BooleanOptional"
    ] = None,
) -> "capo_docdb.types.failover_global_cluster_result.FailoverGlobalClusterResult":
    """<p>Promotes the specified secondary DB cluster to be the primary DB cluster in the global cluster when failing over a global cluster occurs.</p> <p>Use this operation to respond to an unplanned event, such as a regional disaster in the primary region. Failing over can result in a loss of write transaction data that wasn't replicated to the chosen secondary before the failover event occurred. However, the recovery process that promotes a DB instance on the chosen seconday DB cluster to be the primary writer DB instance guarantees that the data is in a transactionally consistent state.</p>

    Args:
        global_cluster_identifier: <p>The identifier of the Amazon DocumentDB global cluster to apply this operation. The identifier is the unique key assigned by the user when the cluster is created. In other words, it's the name of the global cluster.</p> <p>Constraints:</p> <ul> <li> <p>Must match the identifier of an existing global cluster.</p> </li> <li> <p>Minimum length of 1. Maximum length of 255.</p> </li> </ul> <p>Pattern: <code>[A-Za-z][0-9A-Za-z-:._]*</code> </p>
        target_db_cluster_identifier: <p>The identifier of the secondary Amazon DocumentDB cluster that you want to promote to the primary for the global cluster. Use the Amazon Resource Name (ARN) for the identifier so that Amazon DocumentDB can locate the cluster in its Amazon Web Services region.</p> <p>Constraints:</p> <ul> <li> <p>Must match the identifier of an existing secondary cluster.</p> </li> <li> <p>Minimum length of 1. Maximum length of 255.</p> </li> </ul> <p>Pattern: <code>[A-Za-z][0-9A-Za-z-:._]*</code> </p>
        allow_data_loss: <p>Specifies whether to allow data loss for this global cluster operation. Allowing data loss triggers a global failover operation.</p> <p>If you don't specify <code>AllowDataLoss</code>, the global cluster operation defaults to a switchover.</p> <p>Constraints:</p> <ul> <li> <p>Can't be specified together with the <code>Switchover</code> parameter.</p> </li> </ul>
        switchover: <p>Specifies whether to switch over this global database cluster.</p> <p>Constraints:</p> <ul> <li> <p>Can't be specified together with the <code>AllowDataLoss</code> parameter.</p> </li> </ul>

    Raises:
        capo_docdb.errors.db_cluster_not_found_fault.DBClusterNotFoundFault: <p> <code>DBClusterIdentifier</code> doesn't refer to an existing cluster. </p>
        capo_docdb.errors.global_cluster_not_found_fault.GlobalClusterNotFoundFault: <p>The <code>GlobalClusterIdentifier</code> doesn't refer to an existing global cluster.</p>
        capo_docdb.errors.invalid_db_cluster_state_fault.InvalidDBClusterStateFault: <p>The cluster isn't in a valid state.</p>
        capo_docdb.errors.invalid_global_cluster_state_fault.InvalidGlobalClusterStateFault: <p>The requested operation can't be performed while the cluster is in this state.</p>
        capo_docdb.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_docdb.types.failover_global_cluster_message.FailoverGlobalClusterMessage]",
    ) -> AsyncOperationResponse[
        "capo_docdb.types.failover_global_cluster_result.FailoverGlobalClusterResult"
    ]:
        import capo_docdb._operations.amazon_rd_sv19.failover_global_cluster

        (
            output,
            http_response,
        ) = await capo_docdb._operations.amazon_rd_sv19.failover_global_cluster.async_failover_global_cluster(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("FailoverGlobalCluster")
    )
    input_: capo_docdb.types.failover_global_cluster_message.FailoverGlobalClusterMessage = {}
    if global_cluster_identifier is not None:
        input_["global_cluster_identifier"] = global_cluster_identifier
    if target_db_cluster_identifier is not None:
        input_["target_db_cluster_identifier"] = target_db_cluster_identifier
    if allow_data_loss is not None:
        input_["allow_data_loss"] = allow_data_loss
    if switchover is not None:
        input_["switchover"] = switchover

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output