Skip to content

create_relational_database_from_snapshot

create_relational_database_from_snapshot(
    relational_database_name: ResourceName,
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    availability_zone: Optional[string] = None,
    publicly_accessible: Optional[boolean] = None,
    relational_database_snapshot_name: Optional[ResourceName] = None,
    relational_database_bundle_id: Optional[string] = None,
    source_relational_database_name: Optional[ResourceName] = None,
    restore_time: Optional[IsoDate] = None,
    use_latest_restorable_time: Optional[boolean] = None,
    tags: Optional[TagList] = None,
) -> CreateRelationalDatabaseFromSnapshotResult

Creates a new database from an existing database snapshot in Amazon Lightsail.

You can create a new database from a snapshot in if something goes wrong with your original database, or to change it to a different plan, such as a high availability or standard plan.

The create relational database from snapshot operation supports tag-based access control via request tags and resource tags applied to the resource identified by relationalDatabaseSnapshotName. For more information, see the Amazon Lightsail Developer Guide.

Parameters:

  • relational_database_name (ResourceName) –

    The name to use for your new Lightsail database resource.

    Constraints:

    • Must contain from 2 to 255 alphanumeric characters, or hyphens.

    • The first and last character must be a letter or number.

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

    The Availability Zone in which to create your new database. Use the us-east-2a case-sensitive format.

    You can get a list of Availability Zones by using the get regions operation. Be sure to add the include relational database Availability Zones parameter to your request.

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

    Specifies the accessibility options for your new 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.

  • relational_database_snapshot_name (Optional[ResourceName], default: None ) –

    The name of the database snapshot from which to create your new database.

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

    The bundle ID for your new database. A bundle describes the performance specifications for your database.

    You can get a list of database bundle IDs by using the get relational database bundles operation.

    When creating a new database from a snapshot, you cannot choose a bundle that is smaller than the bundle of the source database.

  • source_relational_database_name (Optional[ResourceName], default: None ) –

    The name of the source database.

  • restore_time (Optional[IsoDate], default: None ) –

    The date and time to restore your database from.

    Constraints:

    • Must be before the latest restorable time for the database.

    • Cannot be specified if the use latest restorable time parameter is true.

    • Specified in Coordinated Universal Time (UTC).

    • Specified in the Unix time format.

      For example, if you wish to use a restore time of October 1, 2018, at 8 PM UTC, then you input 1538424000 as the restore time.

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

    Specifies whether your database is restored from the latest backup time. A value of true restores from the latest backup time.

    Default: false

    Constraints: Cannot be specified if the restore time parameter is provided.

  • tags (Optional[TagList], default: None ) –

    The tag keys and optional values to add to the resource during create.

    Use the TagResource action to tag a resource after it's created.

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 create_relational_database_from_snapshot(
    self,
    relational_database_name: "capo_lightsail.types.resource_name.ResourceName",
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    availability_zone: Optional["capo_lightsail.types.string.string"] = None,
    publicly_accessible: Optional["capo_lightsail.types.boolean.boolean"] = None,
    relational_database_snapshot_name: Optional[
        "capo_lightsail.types.resource_name.ResourceName"
    ] = None,
    relational_database_bundle_id: Optional[
        "capo_lightsail.types.string.string"
    ] = None,
    source_relational_database_name: Optional[
        "capo_lightsail.types.resource_name.ResourceName"
    ] = None,
    restore_time: Optional["capo_lightsail.types.iso_date.IsoDate"] = None,
    use_latest_restorable_time: Optional[
        "capo_lightsail.types.boolean.boolean"
    ] = None,
    tags: Optional["capo_lightsail.types.tag_list.TagList"] = None,
) -> "capo_lightsail.types.create_relational_database_from_snapshot_result.CreateRelationalDatabaseFromSnapshotResult":
    """<p>Creates a new database from an existing database snapshot in Amazon Lightsail.</p> <p>You can create a new database from a snapshot in if something goes wrong with your original database, or to change it to a different plan, such as a high availability or standard plan.</p> <p>The <code>create relational database from snapshot</code> operation supports tag-based access control via request tags and resource tags applied to the resource identified by relationalDatabaseSnapshotName. 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 to use for your new Lightsail database resource.</p> <p>Constraints:</p> <ul> <li> <p>Must contain from 2 to 255 alphanumeric characters, or hyphens.</p> </li> <li> <p>The first and last character must be a letter or number.</p> </li> </ul>
        availability_zone: <p>The Availability Zone in which to create your new database. Use the <code>us-east-2a</code> case-sensitive format.</p> <p>You can get a list of Availability Zones by using the <code>get regions</code> operation. Be sure to add the <code>include relational database Availability Zones</code> parameter to your request.</p>
        publicly_accessible: <p>Specifies the accessibility options for your new 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>
        relational_database_snapshot_name: <p>The name of the database snapshot from which to create your new database.</p>
        relational_database_bundle_id: <p>The bundle ID for your new database. A bundle describes the performance specifications for your database.</p> <p>You can get a list of database bundle IDs by using the <code>get relational database bundles</code> operation.</p> <p>When creating a new database from a snapshot, you cannot choose a bundle that is smaller than the bundle of the source database.</p>
        source_relational_database_name: <p>The name of the source database.</p>
        restore_time: <p>The date and time to restore your database from.</p> <p>Constraints:</p> <ul> <li> <p>Must be before the latest restorable time for the database.</p> </li> <li> <p>Cannot be specified if the <code>use latest restorable time</code> parameter is <code>true</code>.</p> </li> <li> <p>Specified in Coordinated Universal Time (UTC).</p> </li> <li> <p>Specified in the Unix time format.</p> <p>For example, if you wish to use a restore time of October 1, 2018, at 8 PM UTC, then you input <code>1538424000</code> as the restore time.</p> </li> </ul>
        use_latest_restorable_time: <p>Specifies whether your database is restored from the latest backup time. A value of <code>true</code> restores from the latest backup time. </p> <p>Default: <code>false</code> </p> <p>Constraints: Cannot be specified if the <code>restore time</code> parameter is provided.</p>
        tags: <p>The tag keys and optional values to add to the resource during create.</p> <p>Use the <code>TagResource</code> action to tag a resource after it's created.</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.create_relational_database_from_snapshot_request.CreateRelationalDatabaseFromSnapshotRequest]",
    ) -> OperationResponse[
        "capo_lightsail.types.create_relational_database_from_snapshot_result.CreateRelationalDatabaseFromSnapshotResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.create_relational_database_from_snapshot

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateRelationalDatabaseFromSnapshot")
    )
    input_: capo_lightsail.types.create_relational_database_from_snapshot_request.CreateRelationalDatabaseFromSnapshotRequest = {
        "relational_database_name": relational_database_name
    }
    if availability_zone is not None:
        input_["availability_zone"] = availability_zone
    if publicly_accessible is not None:
        input_["publicly_accessible"] = publicly_accessible
    if relational_database_snapshot_name is not None:
        input_["relational_database_snapshot_name"] = (
            relational_database_snapshot_name
        )
    if relational_database_bundle_id is not None:
        input_["relational_database_bundle_id"] = relational_database_bundle_id
    if source_relational_database_name is not None:
        input_["source_relational_database_name"] = source_relational_database_name
    if restore_time is not None:
        input_["restore_time"] = restore_time
    if use_latest_restorable_time is not None:
        input_["use_latest_restorable_time"] = use_latest_restorable_time
    if tags is not None:
        input_["tags"] = tags

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