Skip to content

promote_read_replica async

promote_read_replica(
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_instance_identifier: Optional[String] = None,
    backup_retention_period: Optional[IntegerOptional] = None,
    preferred_backup_window: Optional[String] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
) -> PromoteReadReplicaResult

Promotes a read replica DB instance to a standalone DB instance.

  • Backup duration is a function of the amount of changes to the database since the previous backup. If you plan to promote a read replica to a standalone instance, we recommend that you enable backups and complete at least one backup prior to promotion. In addition, a read replica cannot be promoted to a standalone instance when it is in the backing-up status. If you have enabled backups on your read replica, configure the automated backup window so that daily backups do not interfere with read replica promotion.

  • This command doesn't apply to Aurora MySQL, Aurora PostgreSQL, or RDS Custom.

Parameters:

  • db_instance_identifier (Optional[String], default: None ) –

    The DB instance identifier. This value is stored as a lowercase string.

    Constraints:

    • Must match the identifier of an existing read replica DB instance.

    Example: mydbinstance

  • backup_retention_period (Optional[IntegerOptional], default: None ) –

    The number of days for which automated backups are retained. Setting this parameter to a positive number enables backups. Setting this parameter to 0 disables automated backups.

    Default: 1

    Constraints:

    • Must be a value from 0 to 35.

    • Can't be set to 0 if the DB instance is a source to read replicas.

  • preferred_backup_window (Optional[String], default: None ) –

    The daily time range during which automated backups are created if automated backups are enabled, using the BackupRetentionPeriod parameter.

    The default is a 30-minute window selected at random from an 8-hour block of time for each Amazon Web Services Region. To see the time blocks available, see Adjusting the Preferred Maintenance Window in the Amazon RDS User Guide.

    Constraints:

    • Must be in the format hh24:mi-hh24:mi.

    • Must be in Universal Coordinated Time (UTC).

    • Must not conflict with the preferred maintenance window.

    • Must be at least 30 minutes.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    Tags to assign to resources associated with the DB instance.

    Valid Values:

    • auto-backup - The DB instance's automated backup.

Raises:

Examples:

To promote a read replica The following example promotes the specified read replica to become a standalone DB instance.

>>> await client.promote_read_replica(db_instance_identifier='test-instance-repl')
Source code in docs_src/capo_rds/_services/async_rds.py
async def promote_read_replica(
    self,
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_instance_identifier: Optional["capo_rds.types.string.String"] = None,
    backup_retention_period: Optional[
        "capo_rds.types.integer_optional.IntegerOptional"
    ] = None,
    preferred_backup_window: Optional["capo_rds.types.string.String"] = None,
    tag_specifications: Optional[
        "capo_rds.types.tag_specification_list.TagSpecificationList"
    ] = None,
) -> "capo_rds.types.promote_read_replica_result.PromoteReadReplicaResult":
    """<p>Promotes a read replica DB instance to a standalone DB instance.</p> <note> <ul> <li> <p>Backup duration is a function of the amount of changes to the database since the previous backup. If you plan to promote a read replica to a standalone instance, we recommend that you enable backups and complete at least one backup prior to promotion. In addition, a read replica cannot be promoted to a standalone instance when it is in the <code>backing-up</code> status. If you have enabled backups on your read replica, configure the automated backup window so that daily backups do not interfere with read replica promotion.</p> </li> <li> <p>This command doesn't apply to Aurora MySQL, Aurora PostgreSQL, or RDS Custom.</p> </li> </ul> </note>

    Args:
        db_instance_identifier: <p>The DB instance identifier. This value is stored as a lowercase string.</p> <p>Constraints:</p> <ul> <li> <p>Must match the identifier of an existing read replica DB instance.</p> </li> </ul> <p>Example: <code>mydbinstance</code> </p>
        backup_retention_period: <p>The number of days for which automated backups are retained. Setting this parameter to a positive number enables backups. Setting this parameter to 0 disables automated backups.</p> <p>Default: 1</p> <p>Constraints:</p> <ul> <li> <p>Must be a value from 0 to 35.</p> </li> <li> <p>Can't be set to 0 if the DB instance is a source to read replicas.</p> </li> </ul>
        preferred_backup_window: <p>The daily time range during which automated backups are created if automated backups are enabled, using the <code>BackupRetentionPeriod</code> parameter.</p> <p>The default is a 30-minute window selected at random from an 8-hour block of time for each Amazon Web Services Region. To see the time blocks available, see <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/AdjustingTheMaintenanceWindow.html"> Adjusting the Preferred Maintenance Window</a> in the <i>Amazon RDS User Guide.</i> </p> <p>Constraints:</p> <ul> <li> <p>Must be in the format <code>hh24:mi-hh24:mi</code>.</p> </li> <li> <p>Must be in Universal Coordinated Time (UTC).</p> </li> <li> <p>Must not conflict with the preferred maintenance window.</p> </li> <li> <p>Must be at least 30 minutes.</p> </li> </ul>
        tag_specifications: <p>Tags to assign to resources associated with the DB instance.</p> <p>Valid Values: </p> <ul> <li> <p> <code>auto-backup</code> - The DB instance's automated backup.</p> </li> </ul>

    Raises:
        capo_rds.errors.db_instance_not_found_fault.DBInstanceNotFoundFault: <p> <code>DBInstanceIdentifier</code> doesn't refer to an existing DB instance.</p>
        capo_rds.errors.invalid_db_instance_state_fault.InvalidDBInstanceStateFault: <p>The DB instance isn't in a valid state.</p>
        capo_rds.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To promote a read replica
        The following example promotes the specified read replica to become a standalone DB instance.

        >>> await client.promote_read_replica(db_instance_identifier='test-instance-repl')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_rds.types.promote_read_replica_message.PromoteReadReplicaMessage]",
    ) -> AsyncOperationResponse[
        "capo_rds.types.promote_read_replica_result.PromoteReadReplicaResult"
    ]:
        import capo_rds._operations.amazon_rd_sv19.promote_read_replica

        (
            output,
            http_response,
        ) = await capo_rds._operations.amazon_rd_sv19.promote_read_replica.async_promote_read_replica(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_rds.types.promote_read_replica_result.PromoteReadReplicaResult",
    ) -> dict[str, Any]:
        import capo_rds.types.promote_read_replica_result

        return capo_rds.types.promote_read_replica_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("PromoteReadReplica", redact_output=_redact_output),
    )
    input_: capo_rds.types.promote_read_replica_message.PromoteReadReplicaMessage = {}
    if db_instance_identifier is not None:
        input_["db_instance_identifier"] = db_instance_identifier
    if backup_retention_period is not None:
        input_["backup_retention_period"] = backup_retention_period
    if preferred_backup_window is not None:
        input_["preferred_backup_window"] = preferred_backup_window
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications

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