Skip to content

create_tenant_database

create_tenant_database(
    *,
    config_overrides: Optional[RDSClientConfig] = None,
    db_instance_identifier: Optional[String] = None,
    tenant_db_name: Optional[String] = None,
    master_username: Optional[String] = None,
    master_user_password: Optional[SensitiveString] = None,
    character_set_name: Optional[String] = None,
    nchar_character_set_name: Optional[String] = None,
    manage_master_user_password: Optional[BooleanOptional] = None,
    master_user_secret_kms_key_id: Optional[String] = None,
    tags: Optional[TagList] = None,
) -> CreateTenantDatabaseResult

Creates a tenant database in a DB instance that uses the multi-tenant configuration. Only RDS for Oracle container database (CDB) instances are supported.

Parameters:

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

    The user-supplied DB instance identifier. RDS creates your tenant database in this DB instance. This parameter isn't case-sensitive.

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

    The user-supplied name of the tenant database that you want to create in your DB instance. This parameter has the same constraints as DBName in CreateDBInstance.

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

    The name for the master user account in your tenant database. RDS creates this user account in the tenant database and grants privileges to the master user. This parameter is case-sensitive.

    Constraints:

    • Must be 1 to 16 letters, numbers, or underscores.

    • First character must be a letter.

    • Can't be a reserved word for the chosen database engine.

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

    The password for the master user in your tenant database.

    Constraints:

    • Must be 8 to 30 characters.

    • Can include any printable ASCII character except forward slash (/), double quote ("), at symbol (@), ampersand (&), or single quote (').

    • Can't be specified when ManageMasterUserPassword is enabled.

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

    The character set for your tenant database. If you don't specify a value, the character set name defaults to AL32UTF8.

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

    The NCHAR value for the tenant database.

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

    Specifies whether to manage the master user password with Amazon Web Services Secrets Manager.

    For more information, see Password management with Amazon Web Services Secrets Manager in the Amazon RDS User Guide.

    Constraints:

    • Can't manage the master user password with Amazon Web Services Secrets Manager if MasterUserPassword is specified.

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

    The Amazon Web Services KMS key identifier to encrypt a secret that is automatically generated and managed in Amazon Web Services Secrets Manager.

    This setting is valid only if the master user password is managed by RDS in Amazon Web Services Secrets Manager for the DB instance.

    The Amazon Web Services KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key. To use a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN.

    If you don't specify MasterUserSecretKmsKeyId, then the aws/secretsmanager KMS key is used to encrypt the secret. If the secret is in a different Amazon Web Services account, then you can't use the aws/secretsmanager KMS key to encrypt the secret, and you must use a customer managed 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.

Raises:

Source code in docs_src/capo_rds/_services/rds.py
def create_tenant_database(
    self,
    *,
    config_overrides: Optional[RDSClientConfig] = None,
    db_instance_identifier: Optional["capo_rds.types.string.String"] = None,
    tenant_db_name: Optional["capo_rds.types.string.String"] = None,
    master_username: Optional["capo_rds.types.string.String"] = None,
    master_user_password: Optional[
        "capo_rds.types.sensitive_string.SensitiveString"
    ] = None,
    character_set_name: Optional["capo_rds.types.string.String"] = None,
    nchar_character_set_name: Optional["capo_rds.types.string.String"] = None,
    manage_master_user_password: Optional[
        "capo_rds.types.boolean_optional.BooleanOptional"
    ] = None,
    master_user_secret_kms_key_id: Optional["capo_rds.types.string.String"] = None,
    tags: Optional["capo_rds.types.tag_list.TagList"] = None,
) -> "capo_rds.types.create_tenant_database_result.CreateTenantDatabaseResult":
    """<p>Creates a tenant database in a DB instance that uses the multi-tenant configuration. Only RDS for Oracle container database (CDB) instances are supported.</p>

    Args:
        db_instance_identifier: <p>The user-supplied DB instance identifier. RDS creates your tenant database in this DB instance. This parameter isn't case-sensitive.</p>
        tenant_db_name: <p>The user-supplied name of the tenant database that you want to create in your DB instance. This parameter has the same constraints as <code>DBName</code> in <code>CreateDBInstance</code>.</p>
        master_username: <p>The name for the master user account in your tenant database. RDS creates this user account in the tenant database and grants privileges to the master user. This parameter is case-sensitive.</p> <p>Constraints:</p> <ul> <li> <p>Must be 1 to 16 letters, numbers, or underscores.</p> </li> <li> <p>First character must be a letter.</p> </li> <li> <p>Can't be a reserved word for the chosen database engine.</p> </li> </ul>
        master_user_password: <p>The password for the master user in your tenant database.</p> <p>Constraints:</p> <ul> <li> <p>Must be 8 to 30 characters.</p> </li> <li> <p>Can include any printable ASCII character except forward slash (<code>/</code>), double quote (<code>"</code>), at symbol (<code>@</code>), ampersand (<code>&amp;</code>), or single quote (<code>'</code>).</p> </li> <li> <p>Can't be specified when <code>ManageMasterUserPassword</code> is enabled.</p> </li> </ul>
        character_set_name: <p>The character set for your tenant database. If you don't specify a value, the character set name defaults to <code>AL32UTF8</code>.</p>
        nchar_character_set_name: <p>The <code>NCHAR</code> value for the tenant database.</p>
        manage_master_user_password: <p>Specifies whether to manage the master user password with Amazon Web Services Secrets Manager.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-secrets-manager.html">Password management with Amazon Web Services Secrets Manager</a> in the <i>Amazon RDS User Guide.</i> </p> <p>Constraints:</p> <ul> <li> <p>Can't manage the master user password with Amazon Web Services Secrets Manager if <code>MasterUserPassword</code> is specified.</p> </li> </ul>
        master_user_secret_kms_key_id: <p>The Amazon Web Services KMS key identifier to encrypt a secret that is automatically generated and managed in Amazon Web Services Secrets Manager.</p> <p>This setting is valid only if the master user password is managed by RDS in Amazon Web Services Secrets Manager for the DB instance.</p> <p>The Amazon Web Services KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key. To use a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN.</p> <p>If you don't specify <code>MasterUserSecretKmsKeyId</code>, then the <code>aws/secretsmanager</code> KMS key is used to encrypt the secret. If the secret is in a different Amazon Web Services account, then you can't use the <code>aws/secretsmanager</code> KMS key to encrypt the secret, and you must use a customer managed KMS key.</p> <p>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>

    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.kms_key_not_accessible_fault.KMSKeyNotAccessibleFault: <p>An error occurred accessing an Amazon Web Services KMS key.</p>
        capo_rds.errors.tenant_database_already_exists_fault.TenantDatabaseAlreadyExistsFault: <p>You attempted to either create a tenant database that already exists or modify a tenant database to use the name of an existing tenant database.</p>
        capo_rds.errors.tenant_database_quota_exceeded_fault.TenantDatabaseQuotaExceededFault: <p>You attempted to create more tenant databases than are permitted in your Amazon Web Services account.</p>
        capo_rds.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_rds.types.create_tenant_database_message.CreateTenantDatabaseMessage]",
    ) -> OperationResponse[
        "capo_rds.types.create_tenant_database_result.CreateTenantDatabaseResult"
    ]:
        import capo_rds._operations.amazon_rd_sv19.create_tenant_database

        output, http_response = (
            capo_rds._operations.amazon_rd_sv19.create_tenant_database.create_tenant_database(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_rds.types.create_tenant_database_message.CreateTenantDatabaseMessage",
    ) -> dict[str, Any]:
        import capo_rds.types.create_tenant_database_message

        return capo_rds.types.create_tenant_database_message.redact_sensitive(
            input_
        )

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

        return capo_rds.types.create_tenant_database_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateTenantDatabase",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_rds.types.create_tenant_database_message.CreateTenantDatabaseMessage = {}
    if db_instance_identifier is not None:
        input_["db_instance_identifier"] = db_instance_identifier
    if tenant_db_name is not None:
        input_["tenant_db_name"] = tenant_db_name
    if master_username is not None:
        input_["master_username"] = master_username
    if master_user_password is not None:
        input_["master_user_password"] = master_user_password
    if character_set_name is not None:
        input_["character_set_name"] = character_set_name
    if nchar_character_set_name is not None:
        input_["nchar_character_set_name"] = nchar_character_set_name
    if manage_master_user_password is not None:
        input_["manage_master_user_password"] = manage_master_user_password
    if master_user_secret_kms_key_id is not None:
        input_["master_user_secret_kms_key_id"] = master_user_secret_kms_key_id
    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