Skip to content

update_relational_database

update_relational_database(
    relational_database_name: ResourceName,
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    master_user_password: Optional[SensitiveString] = None,
    rotate_master_user_password: Optional[boolean] = None,
    preferred_backup_window: Optional[string] = None,
    preferred_maintenance_window: Optional[string] = None,
    enable_backup_retention: Optional[boolean] = None,
    disable_backup_retention: Optional[boolean] = None,
    publicly_accessible: Optional[boolean] = None,
    apply_immediately: Optional[boolean] = None,
    ca_certificate_identifier: Optional[string] = None,
    relational_database_blueprint_id: Optional[string] = None,
) -> UpdateRelationalDatabaseResult

Allows the update of one or more attributes of a database in Amazon Lightsail.

Updates are applied immediately, or in cases where the updates could result in an outage, are applied during the database's predefined maintenance window.

The update relational database operation supports tag-based access control via resource tags applied to the resource identified by relationalDatabaseName. For more information, see the Amazon Lightsail Developer Guide.

Parameters:

  • relational_database_name (ResourceName) –

    The name of your Lightsail database resource to update.

  • master_user_password (Optional[SensitiveString], default: None ) –

    The password for the master user. The password can include any printable ASCII character except "/", """, or "@".

    MySQL

    Constraints: Must contain from 8 to 41 characters.

    PostgreSQL

    Constraints: Must contain from 8 to 128 characters.

  • rotate_master_user_password (Optional[boolean], default: None ) –

    When true, the master user password is changed to a new strong password generated by Lightsail.

    Use the get relational database master user password operation to get the new password.

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

    The daily time range during which automated backups are created for your database if automated backups are enabled.

    Constraints:

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

      Example: 16:00-16:30

    • Specified in Coordinated Universal Time (UTC).

    • Must not conflict with the preferred maintenance window.

    • Must be at least 30 minutes.

  • preferred_maintenance_window (Optional[string], default: None ) –

    The weekly time range during which system maintenance can occur on your database.

    The default is a 30-minute window selected at random from an 8-hour block of time for each Amazon Web Services Region, occurring on a random day of the week.

    Constraints:

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

    • Valid days: Mon, Tue, Wed, Thu, Fri, Sat, Sun.

    • Must be at least 30 minutes.

    • Specified in Coordinated Universal Time (UTC).

    • Example: Tue:17:00-Tue:17:30

  • enable_backup_retention (Optional[boolean], default: None ) –

    When true, enables automated backup retention for your database.

    Updates are applied during the next maintenance window because this can result in an outage.

  • disable_backup_retention (Optional[boolean], default: None ) –

    When true, disables automated backup retention for your database.

    Disabling backup retention deletes all automated database backups. Before disabling this, you may want to create a snapshot of your database using the create relational database snapshot operation.

    Updates are applied during the next maintenance window because this can result in an outage.

  • publicly_accessible (Optional[boolean], default: None ) –

    Specifies the accessibility options for your database. A value of true specifies a database that is available to resources outside of your Lightsail account. A value of false specifies a database that is available only to your Lightsail resources in the same region as your database.

  • apply_immediately (Optional[boolean], default: None ) –

    When true, applies changes immediately. When false, applies changes during the preferred maintenance window. Some changes may cause an outage.

    Default: false

  • ca_certificate_identifier (Optional[string], default: None ) –

    Indicates the certificate that needs to be associated with the database.

  • relational_database_blueprint_id (Optional[string], default: None ) –

    This parameter is used to update the major version of the database. Enter the blueprintId for the major version that you want to update to.

    Use the GetRelationalDatabaseBlueprints action to get a list of available blueprint IDs.

Raises:

  • AccessDeniedException –

    Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.

  • AccountSetupInProgressException –

    Lightsail throws this exception when an account is still in the setup in progress state.

  • InvalidInputException –

    Lightsail throws this exception when user input does not conform to the validation rules of an input field.

    Domain and distribution APIs are only available in the N. Virginia (us-east-1) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to us-east-1 to create, view, or edit these resources.

  • NotFoundException –

    Lightsail throws this exception when it cannot find a resource.

  • OperationFailureException –

    Lightsail throws this exception when an operation fails to execute.

  • RegionSetupInProgressException –

    Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.

  • ServiceException –

    A general service exception.

  • UnauthenticatedException –

    Lightsail throws this exception when the user has not been authenticated.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_lightsail/_services/lightsail.py
def update_relational_database(
    self,
    relational_database_name: "capo_lightsail.types.resource_name.ResourceName",
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    master_user_password: Optional[
        "capo_lightsail.types.sensitive_string.SensitiveString"
    ] = None,
    rotate_master_user_password: Optional[
        "capo_lightsail.types.boolean.boolean"
    ] = None,
    preferred_backup_window: Optional["capo_lightsail.types.string.string"] = None,
    preferred_maintenance_window: Optional[
        "capo_lightsail.types.string.string"
    ] = None,
    enable_backup_retention: Optional[
        "capo_lightsail.types.boolean.boolean"
    ] = None,
    disable_backup_retention: Optional[
        "capo_lightsail.types.boolean.boolean"
    ] = None,
    publicly_accessible: Optional["capo_lightsail.types.boolean.boolean"] = None,
    apply_immediately: Optional["capo_lightsail.types.boolean.boolean"] = None,
    ca_certificate_identifier: Optional[
        "capo_lightsail.types.string.string"
    ] = None,
    relational_database_blueprint_id: Optional[
        "capo_lightsail.types.string.string"
    ] = None,
) -> "capo_lightsail.types.update_relational_database_result.UpdateRelationalDatabaseResult":
    """<p>Allows the update of one or more attributes of a database in Amazon Lightsail.</p> <p>Updates are applied immediately, or in cases where the updates could result in an outage, are applied during the database's predefined maintenance window.</p> <p>The <code>update relational database</code> operation supports tag-based access control via resource tags applied to the resource identified by relationalDatabaseName. For more information, see the <a href=\"https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags\">Amazon Lightsail Developer Guide</a>.</p>

    Args:
        relational_database_name: <p>The name of your Lightsail database resource to update.</p>
        master_user_password: <p>The password for the master user. The password can include any printable ASCII character except \"/\", \"\"\", or \"@\".</p> <p>My<b>SQL</b> </p> <p>Constraints: Must contain from 8 to 41 characters.</p> <p> <b>PostgreSQL</b> </p> <p>Constraints: Must contain from 8 to 128 characters.</p>
        rotate_master_user_password: <p>When <code>true</code>, the master user password is changed to a new strong password generated by Lightsail.</p> <p>Use the <code>get relational database master user password</code> operation to get the new password.</p>
        preferred_backup_window: <p>The daily time range during which automated backups are created for your database if automated backups are enabled.</p> <p>Constraints:</p> <ul> <li> <p>Must be in the <code>hh24:mi-hh24:mi</code> format.</p> <p>Example: <code>16:00-16:30</code> </p> </li> <li> <p>Specified in Coordinated Universal 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>
        preferred_maintenance_window: <p>The weekly time range during which system maintenance can occur on your database.</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, occurring on a random day of the week.</p> <p>Constraints:</p> <ul> <li> <p>Must be in the <code>ddd:hh24:mi-ddd:hh24:mi</code> format.</p> </li> <li> <p>Valid days: Mon, Tue, Wed, Thu, Fri, Sat, Sun.</p> </li> <li> <p>Must be at least 30 minutes.</p> </li> <li> <p>Specified in Coordinated Universal Time (UTC).</p> </li> <li> <p>Example: <code>Tue:17:00-Tue:17:30</code> </p> </li> </ul>
        enable_backup_retention: <p>When <code>true</code>, enables automated backup retention for your database.</p> <p>Updates are applied during the next maintenance window because this can result in an outage.</p>
        disable_backup_retention: <p>When <code>true</code>, disables automated backup retention for your database.</p> <p>Disabling backup retention deletes all automated database backups. Before disabling this, you may want to create a snapshot of your database using the <code>create relational database snapshot</code> operation.</p> <p>Updates are applied during the next maintenance window because this can result in an outage.</p>
        publicly_accessible: <p>Specifies the accessibility options for your database. A value of <code>true</code> specifies a database that is available to resources outside of your Lightsail account. A value of <code>false</code> specifies a database that is available only to your Lightsail resources in the same region as your database.</p>
        apply_immediately: <p>When <code>true</code>, applies changes immediately. When <code>false</code>, applies changes during the preferred maintenance window. Some changes may cause an outage.</p> <p>Default: <code>false</code> </p>
        ca_certificate_identifier: <p>Indicates the certificate that needs to be associated with the database.</p>
        relational_database_blueprint_id: <p>This parameter is used to update the major version of the database. Enter the <code>blueprintId</code> for the major version that you want to update to.</p> <p>Use the <a href=\"https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRelationalDatabaseBlueprints.html\">GetRelationalDatabaseBlueprints</a> action to get a list of available blueprint IDs.</p>

    Raises:
        capo_lightsail.errors.access_denied_exception.AccessDeniedException: <p>Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.</p>
        capo_lightsail.errors.account_setup_in_progress_exception.AccountSetupInProgressException: <p>Lightsail throws this exception when an account is still in the setup in progress state.</p>
        capo_lightsail.errors.invalid_input_exception.InvalidInputException: <p>Lightsail throws this exception when user input does not conform to the validation rules of an input field.</p> <note> <p>Domain and distribution APIs are only available in the N. Virginia (<code>us-east-1</code>) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to <code>us-east-1</code> to create, view, or edit these resources.</p> </note>
        capo_lightsail.errors.not_found_exception.NotFoundException: <p>Lightsail throws this exception when it cannot find a resource.</p>
        capo_lightsail.errors.operation_failure_exception.OperationFailureException: <p>Lightsail throws this exception when an operation fails to execute.</p>
        capo_lightsail.errors.region_setup_in_progress_exception.RegionSetupInProgressException: <p>Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.</p>
        capo_lightsail.errors.service_exception.ServiceException: <p>A general service exception.</p>
        capo_lightsail.errors.unauthenticated_exception.UnauthenticatedException: <p>Lightsail throws this exception when the user has not been authenticated.</p>
        capo_lightsail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lightsail.types.update_relational_database_request.UpdateRelationalDatabaseRequest]",
    ) -> OperationResponse[
        "capo_lightsail.types.update_relational_database_result.UpdateRelationalDatabaseResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.update_relational_database

        output, http_response = (
            capo_lightsail._operations.lightsail_20161128.update_relational_database.update_relational_database(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_lightsail.types.update_relational_database_request.UpdateRelationalDatabaseRequest",
    ) -> dict[str, Any]:
        import capo_lightsail.types.update_relational_database_request

        return capo_lightsail.types.update_relational_database_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("UpdateRelationalDatabase", redact_input=_redact_input),
    )
    input_: capo_lightsail.types.update_relational_database_request.UpdateRelationalDatabaseRequest = {
        "relational_database_name": relational_database_name
    }
    if master_user_password is not None:
        input_["master_user_password"] = master_user_password
    if rotate_master_user_password is not None:
        input_["rotate_master_user_password"] = rotate_master_user_password
    if preferred_backup_window is not None:
        input_["preferred_backup_window"] = preferred_backup_window
    if preferred_maintenance_window is not None:
        input_["preferred_maintenance_window"] = preferred_maintenance_window
    if enable_backup_retention is not None:
        input_["enable_backup_retention"] = enable_backup_retention
    if disable_backup_retention is not None:
        input_["disable_backup_retention"] = disable_backup_retention
    if publicly_accessible is not None:
        input_["publicly_accessible"] = publicly_accessible
    if apply_immediately is not None:
        input_["apply_immediately"] = apply_immediately
    if ca_certificate_identifier is not None:
        input_["ca_certificate_identifier"] = ca_certificate_identifier
    if relational_database_blueprint_id is not None:
        input_["relational_database_blueprint_id"] = (
            relational_database_blueprint_id
        )

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output