Skip to content

create_db_instance async

create_db_instance(
    *,
    config_overrides: Optional[AsyncDocDBClientConfig] = None,
    db_instance_identifier: Optional[String] = None,
    db_instance_class: Optional[String] = None,
    engine: Optional[String] = None,
    availability_zone: Optional[String] = None,
    preferred_maintenance_window: Optional[String] = None,
    auto_minor_version_upgrade: Optional[BooleanOptional] = None,
    tags: Optional[TagList] = None,
    db_cluster_identifier: Optional[String] = None,
    copy_tags_to_snapshot: Optional[BooleanOptional] = None,
    promotion_tier: Optional[IntegerOptional] = None,
    enable_performance_insights: Optional[BooleanOptional] = None,
    performance_insights_kms_key_id: Optional[String] = None,
    ca_certificate_identifier: Optional[String] = None,
) -> CreateDBInstanceResult

Creates a new instance.

Parameters:

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

    The instance identifier. This parameter is stored as a lowercase string.

    Constraints:

    • Must contain from 1 to 63 letters, numbers, or hyphens.

    • The first character must be a letter.

    • Cannot end with a hyphen or contain two consecutive hyphens.

    Example: mydbinstance

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

    The compute and memory capacity of the instance; for example, db.r5.large.

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

    The name of the database engine to be used for this instance.

    Valid value: docdb

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

    The Amazon EC2 Availability Zone that the instance is created in.

    Default: A random, system-chosen Availability Zone in the endpoint's Amazon Web Services Region.

    Example: us-east-1d

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

    The time range each week during which system maintenance can occur, in Universal Coordinated Time (UTC).

    Format: ddd:hh24:mi-ddd:hh24:mi

    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.

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

    Constraints: Minimum 30-minute window.

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

    This parameter does not apply to Amazon DocumentDB. Amazon DocumentDB does not perform minor version upgrades regardless of the value set.

    Default: false

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

    The tags to be assigned to the instance. You can assign up to 10 tags to an instance.

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

    The identifier of the cluster that the instance will belong to.

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

    A value that indicates whether to copy tags from the DB instance to snapshots of the DB instance. By default, tags are not copied.

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

    A value that specifies the order in which an Amazon DocumentDB replica is promoted to the primary instance after a failure of the existing primary instance.

    Default: 1

    Valid values: 0-15

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

    A value that indicates whether to enable Performance Insights for the DB Instance. For more information, see Using Amazon Performance Insights.

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

    The KMS key identifier for encryption of Performance Insights data.

    The KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key.

    If you do not specify a value for PerformanceInsightsKMSKeyId, then Amazon DocumentDB uses your default KMS key. There is a default KMS key for your Amazon Web Services account. Your Amazon Web Services account has a different default KMS key for each Amazon Web Services region.

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

    The CA certificate identifier to use for the DB instance's server certificate.

    For more information, see Updating Your Amazon DocumentDB TLS Certificates and Encrypting Data in Transit in the Amazon DocumentDB Developer Guide.

Raises:

Source code in docs_src/capo_docdb/_services/async_doc_db.py
async def create_db_instance(
    self,
    *,
    config_overrides: Optional[AsyncDocDBClientConfig] = None,
    db_instance_identifier: Optional["capo_docdb.types.string.String"] = None,
    db_instance_class: Optional["capo_docdb.types.string.String"] = None,
    engine: Optional["capo_docdb.types.string.String"] = None,
    availability_zone: Optional["capo_docdb.types.string.String"] = None,
    preferred_maintenance_window: Optional["capo_docdb.types.string.String"] = None,
    auto_minor_version_upgrade: Optional[
        "capo_docdb.types.boolean_optional.BooleanOptional"
    ] = None,
    tags: Optional["capo_docdb.types.tag_list.TagList"] = None,
    db_cluster_identifier: Optional["capo_docdb.types.string.String"] = None,
    copy_tags_to_snapshot: Optional[
        "capo_docdb.types.boolean_optional.BooleanOptional"
    ] = None,
    promotion_tier: Optional[
        "capo_docdb.types.integer_optional.IntegerOptional"
    ] = None,
    enable_performance_insights: Optional[
        "capo_docdb.types.boolean_optional.BooleanOptional"
    ] = None,
    performance_insights_kms_key_id: Optional[
        "capo_docdb.types.string.String"
    ] = None,
    ca_certificate_identifier: Optional["capo_docdb.types.string.String"] = None,
) -> "capo_docdb.types.create_db_instance_result.CreateDBInstanceResult":
    """<p>Creates a new instance.</p>

    Args:
        db_instance_identifier: <p>The instance identifier. This parameter is stored as a lowercase string.</p> <p>Constraints:</p> <ul> <li> <p>Must contain from 1 to 63 letters, numbers, or hyphens.</p> </li> <li> <p>The first character must be a letter.</p> </li> <li> <p>Cannot end with a hyphen or contain two consecutive hyphens.</p> </li> </ul> <p>Example: <code>mydbinstance</code> </p>
        db_instance_class: <p>The compute and memory capacity of the instance; for example, <code>db.r5.large</code>. </p>
        engine: <p>The name of the database engine to be used for this instance.</p> <p>Valid value: <code>docdb</code> </p>
        availability_zone: <p>The Amazon EC2 Availability Zone that the instance is created in. </p> <p>Default: A random, system-chosen Availability Zone in the endpoint's Amazon Web Services Region.</p> <p>Example: <code>us-east-1d</code> </p>
        preferred_maintenance_window: <p>The time range each week during which system maintenance can occur, in Universal Coordinated Time (UTC).</p> <p> Format: <code>ddd:hh24:mi-ddd:hh24:mi</code> </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>Valid days: Mon, Tue, Wed, Thu, Fri, Sat, Sun</p> <p>Constraints: Minimum 30-minute window.</p>
        auto_minor_version_upgrade: <p>This parameter does not apply to Amazon DocumentDB. Amazon DocumentDB does not perform minor version upgrades regardless of the value set.</p> <p>Default: <code>false</code> </p>
        tags: <p>The tags to be assigned to the instance. You can assign up to 10 tags to an instance.</p>
        db_cluster_identifier: <p>The identifier of the cluster that the instance will belong to.</p>
        copy_tags_to_snapshot: <p>A value that indicates whether to copy tags from the DB instance to snapshots of the DB instance. By default, tags are not copied.</p>
        promotion_tier: <p>A value that specifies the order in which an Amazon DocumentDB replica is promoted to the primary instance after a failure of the existing primary instance.</p> <p>Default: 1</p> <p>Valid values: 0-15</p>
        enable_performance_insights: <p>A value that indicates whether to enable Performance Insights for the DB Instance. For more information, see <a href="https://docs.aws.amazon.com/documentdb/latest/devguide/performance-insights.html">Using Amazon Performance Insights</a>.</p>
        performance_insights_kms_key_id: <p>The KMS key identifier for encryption of Performance Insights data.</p> <p>The KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key.</p> <p>If you do not specify a value for PerformanceInsightsKMSKeyId, then Amazon DocumentDB uses your default KMS key. There is a default KMS key for your Amazon Web Services account. Your Amazon Web Services account has a different default KMS key for each Amazon Web Services region.</p>
        ca_certificate_identifier: <p>The CA certificate identifier to use for the DB instance's server certificate.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/documentdb/latest/devguide/ca_cert_rotation.html">Updating Your Amazon DocumentDB TLS Certificates</a> and <a href="https://docs.aws.amazon.com/documentdb/latest/devguide/security.encryption.ssl.html"> Encrypting Data in Transit</a> in the <i>Amazon DocumentDB Developer Guide</i>.</p>

    Raises:
        capo_docdb.errors.authorization_not_found_fault.AuthorizationNotFoundFault: <p>The specified CIDR IP or Amazon EC2 security group isn't authorized for the specified security group.</p> <p>Amazon DocumentDB also might not be authorized to perform necessary actions on your behalf using IAM.</p>
        capo_docdb.errors.db_cluster_not_found_fault.DBClusterNotFoundFault: <p> <code>DBClusterIdentifier</code> doesn't refer to an existing cluster. </p>
        capo_docdb.errors.db_instance_already_exists_fault.DBInstanceAlreadyExistsFault: <p>You already have a instance with the given identifier.</p>
        capo_docdb.errors.db_parameter_group_not_found_fault.DBParameterGroupNotFoundFault: <p> <code>DBParameterGroupName</code> doesn't refer to an existing parameter group. </p>
        capo_docdb.errors.db_security_group_not_found_fault.DBSecurityGroupNotFoundFault: <p> <code>DBSecurityGroupName</code> doesn't refer to an existing security group. </p>
        capo_docdb.errors.db_subnet_group_does_not_cover_enough_a_zs.DBSubnetGroupDoesNotCoverEnoughAZs: <p>Subnets in the subnet group should cover at least two Availability Zones unless there is only one Availability Zone.</p>
        capo_docdb.errors.db_subnet_group_not_found_fault.DBSubnetGroupNotFoundFault: <p> <code>DBSubnetGroupName</code> doesn't refer to an existing subnet group. </p>
        capo_docdb.errors.instance_quota_exceeded_fault.InstanceQuotaExceededFault: <p>The request would cause you to exceed the allowed number of instances.</p>
        capo_docdb.errors.insufficient_db_instance_capacity_fault.InsufficientDBInstanceCapacityFault: <p>The specified instance class isn't available in the specified Availability Zone.</p>
        capo_docdb.errors.invalid_db_cluster_state_fault.InvalidDBClusterStateFault: <p>The cluster isn't in a valid state.</p>
        capo_docdb.errors.invalid_subnet.InvalidSubnet: <p>The requested subnet is not valid, or multiple subnets were requested that are not all in a common virtual private cloud (VPC).</p>
        capo_docdb.errors.invalid_vpc_network_state_fault.InvalidVPCNetworkStateFault: <p>The subnet group doesn't cover all Availability Zones after it is created because of changes that were made.</p>
        capo_docdb.errors.kms_key_not_accessible_fault.KMSKeyNotAccessibleFault: <p>An error occurred when accessing an KMS key.</p>
        capo_docdb.errors.storage_quota_exceeded_fault.StorageQuotaExceededFault: <p>The request would cause you to exceed the allowed amount of storage available across all instances.</p>
        capo_docdb.errors.storage_type_not_supported_fault.StorageTypeNotSupportedFault: <p>Storage of the specified <code>StorageType</code> can't be associated with the DB instance. </p>
        capo_docdb.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_docdb.types.create_db_instance_message.CreateDBInstanceMessage]",
    ) -> AsyncOperationResponse[
        "capo_docdb.types.create_db_instance_result.CreateDBInstanceResult"
    ]:
        import capo_docdb._operations.amazon_rd_sv19.create_db_instance

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateDBInstance")
    )
    input_: capo_docdb.types.create_db_instance_message.CreateDBInstanceMessage = {}
    if db_instance_identifier is not None:
        input_["db_instance_identifier"] = db_instance_identifier
    if db_instance_class is not None:
        input_["db_instance_class"] = db_instance_class
    if engine is not None:
        input_["engine"] = engine
    if availability_zone is not None:
        input_["availability_zone"] = availability_zone
    if preferred_maintenance_window is not None:
        input_["preferred_maintenance_window"] = preferred_maintenance_window
    if auto_minor_version_upgrade is not None:
        input_["auto_minor_version_upgrade"] = auto_minor_version_upgrade
    if tags is not None:
        input_["tags"] = tags
    if db_cluster_identifier is not None:
        input_["db_cluster_identifier"] = db_cluster_identifier
    if copy_tags_to_snapshot is not None:
        input_["copy_tags_to_snapshot"] = copy_tags_to_snapshot
    if promotion_tier is not None:
        input_["promotion_tier"] = promotion_tier
    if enable_performance_insights is not None:
        input_["enable_performance_insights"] = enable_performance_insights
    if performance_insights_kms_key_id is not None:
        input_["performance_insights_kms_key_id"] = performance_insights_kms_key_id
    if ca_certificate_identifier is not None:
        input_["ca_certificate_identifier"] = ca_certificate_identifier

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