# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import json
import warnings
import pulumi
import pulumi.runtime
from typing import Union
from .. import utilities, tables

class Instance(pulumi.CustomResource):
    auto_renew: pulumi.Output[bool]
    """
    Whether to renewal a DB instance automatically or not. It is valid when instance_charge_type is `PrePaid`. Default to `false`.
    """
    auto_renew_period: pulumi.Output[float]
    """
    Auto-renewal period of an instance, in the unit of the month. It is valid when instance_charge_type is `PrePaid`. Valid value:[1~12], Default to 1.
    """
    auto_upgrade_minor_version: pulumi.Output[str]
    """
    The upgrade method to use. Valid values:
    - Auto: Instances are automatically upgraded to a higher minor version.
    - Manual: Instances are forcibly upgraded to a higher minor version when the current version is unpublished.
    """
    connection_string: pulumi.Output[str]
    """
    RDS database connection string.
    """
    db_instance_storage_type: pulumi.Output[str]
    """
    The storage type of the instance. Valid values:
    - local_ssd: specifies to use local SSDs. This value is recommended.
    - cloud_ssd: specifies to use standard SSDs.
    - cloud_essd: specifies to use enhanced SSDs (ESSDs).
    - cloud_essd2: specifies to use enhanced SSDs (ESSDs).
    - cloud_essd3: specifies to use enhanced SSDs (ESSDs).
    """
    engine: pulumi.Output[str]
    """
    Database type. Value options: MySQL, SQLServer, PostgreSQL, and PPAS.
    """
    engine_version: pulumi.Output[str]
    """
    Database version. Value options can refer to the latest docs [CreateDBInstance](https://www.alibabacloud.com/help/doc-detail/26228.htm) `EngineVersion`.
    """
    instance_charge_type: pulumi.Output[str]
    """
    Valid values are `Prepaid`, `Postpaid`, Default to `Postpaid`. Currently, the resource only supports PostPaid to PrePaid.
    """
    instance_name: pulumi.Output[str]
    """
    The name of DB instance. It a string of 2 to 256 characters.
    """
    instance_storage: pulumi.Output[float]
    """
    User-defined DB instance storage space. Value range:
    - [5, 2000] for MySQL/PostgreSQL/PPAS HA dual node edition;
    - [20,1000] for MySQL 5.7 basic single node edition;
    - [10, 2000] for SQL Server 2008R2;
    - [20,2000] for SQL Server 2012 basic single node edition
    Increase progressively at a rate of 5 GB. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/26312.htm).
    Note: There is extra 5 GB storage for SQL Server Instance and it is not in specified `instance_storage`.
    """
    instance_type: pulumi.Output[str]
    """
    DB Instance type. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/26312.htm).
    """
    maintain_time: pulumi.Output[str]
    """
    Maintainable time period format of the instance: HH:MMZ-HH:MMZ (UTC time)
    """
    monitoring_period: pulumi.Output[float]
    """
    The monitoring frequency in seconds. Valid values are 5, 60, 300. Defaults to 300. 
    """
    parameters: pulumi.Output[list]
    """
    Set of parameters needs to be set after DB instance was launched. Available parameters can refer to the latest docs [View database parameter templates](https://www.alibabacloud.com/help/doc-detail/26284.htm) .
    
      * `name` (`str`)
      * `value` (`str`)
    """
    period: pulumi.Output[float]
    """
    The duration that you will buy DB instance (in month). It is valid when instance_charge_type is `PrePaid`. Valid values: [1~9], 12, 24, 36. Default to 1.
    """
    port: pulumi.Output[str]
    """
    RDS database connection port.
    """
    security_group_id: pulumi.Output[str]
    """
    It has been deprecated from 1.69.0 and use `security_group_ids` instead.
    """
    security_group_ids: pulumi.Output[list]
    """
    , Available in 1.69.0+) The list IDs to join ECS Security Group. At most supports three security groups.
    """
    security_ip_mode: pulumi.Output[str]
    """
    Valid values are `normal`, `safety`, Default to `normal`. support `safety` switch to high security access mode 
    """
    security_ips: pulumi.Output[list]
    """
    List of IP addresses allowed to access all databases of an instance. The list contains up to 1,000 IP addresses, separated by commas. Supported formats include 0.0.0.0/0, 10.23.12.24 (IP), and 10.23.12.24/24 (Classless Inter-Domain Routing (CIDR) mode. /24 represents the length of the prefix in an IP address. The range of the prefix length is [1,32]).
    """
    sql_collector_config_value: pulumi.Output[float]
    """
    The sql collector keep time of the instance. Valid values are `1`, `30`, `180`, `365`, `1095`, `1825`, `1` is the initial value, and can't change it to `1`.
    """
    sql_collector_status: pulumi.Output[str]
    """
    The sql collector status of the instance. Valid values are `Enabled`, `Disabled`, Default to `Disabled`.
    """
    tags: pulumi.Output[dict]
    """
    A mapping of tags to assign to the resource.
    - Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
    - Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
    """
    vswitch_id: pulumi.Output[str]
    """
    The virtual switch ID to launch DB instances in one VPC.
    """
    zone_id: pulumi.Output[str]
    """
    The Zone to launch the DB instance. From version 1.8.1, it supports multiple zone.
    If it is a multi-zone and `vswitch_id` is specified, the vswitch must in the one of them.
    The multiple zone ID can be retrieved by setting `multi` to "true" in the data source `.getZones`.
    """
    def __init__(__self__, resource_name, opts=None, auto_renew=None, auto_renew_period=None, auto_upgrade_minor_version=None, db_instance_storage_type=None, engine=None, engine_version=None, instance_charge_type=None, instance_name=None, instance_storage=None, instance_type=None, maintain_time=None, monitoring_period=None, parameters=None, period=None, security_group_id=None, security_group_ids=None, security_ip_mode=None, security_ips=None, sql_collector_config_value=None, sql_collector_status=None, tags=None, vswitch_id=None, zone_id=None, __props__=None, __name__=None, __opts__=None):
        """
        Provides an RDS instance resource. A DB instance is an isolated database
        environment in the cloud. A DB instance can contain multiple user-created
        databases.
        
        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[bool] auto_renew: Whether to renewal a DB instance automatically or not. It is valid when instance_charge_type is `PrePaid`. Default to `false`.
        :param pulumi.Input[float] auto_renew_period: Auto-renewal period of an instance, in the unit of the month. It is valid when instance_charge_type is `PrePaid`. Valid value:[1~12], Default to 1.
        :param pulumi.Input[str] auto_upgrade_minor_version: The upgrade method to use. Valid values:
               - Auto: Instances are automatically upgraded to a higher minor version.
               - Manual: Instances are forcibly upgraded to a higher minor version when the current version is unpublished.
        :param pulumi.Input[str] db_instance_storage_type: The storage type of the instance. Valid values:
               - local_ssd: specifies to use local SSDs. This value is recommended.
               - cloud_ssd: specifies to use standard SSDs.
               - cloud_essd: specifies to use enhanced SSDs (ESSDs).
               - cloud_essd2: specifies to use enhanced SSDs (ESSDs).
               - cloud_essd3: specifies to use enhanced SSDs (ESSDs).
        :param pulumi.Input[str] engine: Database type. Value options: MySQL, SQLServer, PostgreSQL, and PPAS.
        :param pulumi.Input[str] engine_version: Database version. Value options can refer to the latest docs [CreateDBInstance](https://www.alibabacloud.com/help/doc-detail/26228.htm) `EngineVersion`.
        :param pulumi.Input[str] instance_charge_type: Valid values are `Prepaid`, `Postpaid`, Default to `Postpaid`. Currently, the resource only supports PostPaid to PrePaid.
        :param pulumi.Input[str] instance_name: The name of DB instance. It a string of 2 to 256 characters.
        :param pulumi.Input[float] instance_storage: User-defined DB instance storage space. Value range:
               - [5, 2000] for MySQL/PostgreSQL/PPAS HA dual node edition;
               - [20,1000] for MySQL 5.7 basic single node edition;
               - [10, 2000] for SQL Server 2008R2;
               - [20,2000] for SQL Server 2012 basic single node edition
               Increase progressively at a rate of 5 GB. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/26312.htm).
               Note: There is extra 5 GB storage for SQL Server Instance and it is not in specified `instance_storage`.
        :param pulumi.Input[str] instance_type: DB Instance type. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/26312.htm).
        :param pulumi.Input[str] maintain_time: Maintainable time period format of the instance: HH:MMZ-HH:MMZ (UTC time)
        :param pulumi.Input[float] monitoring_period: The monitoring frequency in seconds. Valid values are 5, 60, 300. Defaults to 300. 
        :param pulumi.Input[list] parameters: Set of parameters needs to be set after DB instance was launched. Available parameters can refer to the latest docs [View database parameter templates](https://www.alibabacloud.com/help/doc-detail/26284.htm) .
        :param pulumi.Input[float] period: The duration that you will buy DB instance (in month). It is valid when instance_charge_type is `PrePaid`. Valid values: [1~9], 12, 24, 36. Default to 1.
        :param pulumi.Input[str] security_group_id: It has been deprecated from 1.69.0 and use `security_group_ids` instead.
        :param pulumi.Input[list] security_group_ids: , Available in 1.69.0+) The list IDs to join ECS Security Group. At most supports three security groups.
        :param pulumi.Input[str] security_ip_mode: Valid values are `normal`, `safety`, Default to `normal`. support `safety` switch to high security access mode 
        :param pulumi.Input[list] security_ips: List of IP addresses allowed to access all databases of an instance. The list contains up to 1,000 IP addresses, separated by commas. Supported formats include 0.0.0.0/0, 10.23.12.24 (IP), and 10.23.12.24/24 (Classless Inter-Domain Routing (CIDR) mode. /24 represents the length of the prefix in an IP address. The range of the prefix length is [1,32]).
        :param pulumi.Input[float] sql_collector_config_value: The sql collector keep time of the instance. Valid values are `1`, `30`, `180`, `365`, `1095`, `1825`, `1` is the initial value, and can't change it to `1`.
        :param pulumi.Input[str] sql_collector_status: The sql collector status of the instance. Valid values are `Enabled`, `Disabled`, Default to `Disabled`.
        :param pulumi.Input[dict] tags: A mapping of tags to assign to the resource.
               - Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
               - Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
        :param pulumi.Input[str] vswitch_id: The virtual switch ID to launch DB instances in one VPC.
        :param pulumi.Input[str] zone_id: The Zone to launch the DB instance. From version 1.8.1, it supports multiple zone.
               If it is a multi-zone and `vswitch_id` is specified, the vswitch must in the one of them.
               The multiple zone ID can be retrieved by setting `multi` to "true" in the data source `.getZones`.
        
        The **parameters** object supports the following:
        
          * `name` (`pulumi.Input[str]`)
          * `value` (`pulumi.Input[str]`)

        > This content is derived from https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/website/docs/r/db_instance.html.markdown.
        """
        if __name__ is not None:
            warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning)
            resource_name = __name__
        if __opts__ is not None:
            warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning)
            opts = __opts__
        if opts is None:
            opts = pulumi.ResourceOptions()
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.version is None:
            opts.version = utilities.get_version()
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = dict()

            __props__['auto_renew'] = auto_renew
            __props__['auto_renew_period'] = auto_renew_period
            __props__['auto_upgrade_minor_version'] = auto_upgrade_minor_version
            __props__['db_instance_storage_type'] = db_instance_storage_type
            if engine is None:
                raise TypeError("Missing required property 'engine'")
            __props__['engine'] = engine
            if engine_version is None:
                raise TypeError("Missing required property 'engine_version'")
            __props__['engine_version'] = engine_version
            __props__['instance_charge_type'] = instance_charge_type
            __props__['instance_name'] = instance_name
            if instance_storage is None:
                raise TypeError("Missing required property 'instance_storage'")
            __props__['instance_storage'] = instance_storage
            if instance_type is None:
                raise TypeError("Missing required property 'instance_type'")
            __props__['instance_type'] = instance_type
            __props__['maintain_time'] = maintain_time
            __props__['monitoring_period'] = monitoring_period
            __props__['parameters'] = parameters
            __props__['period'] = period
            __props__['security_group_id'] = security_group_id
            __props__['security_group_ids'] = security_group_ids
            __props__['security_ip_mode'] = security_ip_mode
            __props__['security_ips'] = security_ips
            __props__['sql_collector_config_value'] = sql_collector_config_value
            __props__['sql_collector_status'] = sql_collector_status
            __props__['tags'] = tags
            __props__['vswitch_id'] = vswitch_id
            __props__['zone_id'] = zone_id
            __props__['connection_string'] = None
            __props__['port'] = None
        super(Instance, __self__).__init__(
            'alicloud:rds/instance:Instance',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name, id, opts=None, auto_renew=None, auto_renew_period=None, auto_upgrade_minor_version=None, connection_string=None, db_instance_storage_type=None, engine=None, engine_version=None, instance_charge_type=None, instance_name=None, instance_storage=None, instance_type=None, maintain_time=None, monitoring_period=None, parameters=None, period=None, port=None, security_group_id=None, security_group_ids=None, security_ip_mode=None, security_ips=None, sql_collector_config_value=None, sql_collector_status=None, tags=None, vswitch_id=None, zone_id=None):
        """
        Get an existing Instance resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.
        
        :param str resource_name: The unique name of the resulting resource.
        :param str id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[bool] auto_renew: Whether to renewal a DB instance automatically or not. It is valid when instance_charge_type is `PrePaid`. Default to `false`.
        :param pulumi.Input[float] auto_renew_period: Auto-renewal period of an instance, in the unit of the month. It is valid when instance_charge_type is `PrePaid`. Valid value:[1~12], Default to 1.
        :param pulumi.Input[str] auto_upgrade_minor_version: The upgrade method to use. Valid values:
               - Auto: Instances are automatically upgraded to a higher minor version.
               - Manual: Instances are forcibly upgraded to a higher minor version when the current version is unpublished.
        :param pulumi.Input[str] connection_string: RDS database connection string.
        :param pulumi.Input[str] db_instance_storage_type: The storage type of the instance. Valid values:
               - local_ssd: specifies to use local SSDs. This value is recommended.
               - cloud_ssd: specifies to use standard SSDs.
               - cloud_essd: specifies to use enhanced SSDs (ESSDs).
               - cloud_essd2: specifies to use enhanced SSDs (ESSDs).
               - cloud_essd3: specifies to use enhanced SSDs (ESSDs).
        :param pulumi.Input[str] engine: Database type. Value options: MySQL, SQLServer, PostgreSQL, and PPAS.
        :param pulumi.Input[str] engine_version: Database version. Value options can refer to the latest docs [CreateDBInstance](https://www.alibabacloud.com/help/doc-detail/26228.htm) `EngineVersion`.
        :param pulumi.Input[str] instance_charge_type: Valid values are `Prepaid`, `Postpaid`, Default to `Postpaid`. Currently, the resource only supports PostPaid to PrePaid.
        :param pulumi.Input[str] instance_name: The name of DB instance. It a string of 2 to 256 characters.
        :param pulumi.Input[float] instance_storage: User-defined DB instance storage space. Value range:
               - [5, 2000] for MySQL/PostgreSQL/PPAS HA dual node edition;
               - [20,1000] for MySQL 5.7 basic single node edition;
               - [10, 2000] for SQL Server 2008R2;
               - [20,2000] for SQL Server 2012 basic single node edition
               Increase progressively at a rate of 5 GB. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/26312.htm).
               Note: There is extra 5 GB storage for SQL Server Instance and it is not in specified `instance_storage`.
        :param pulumi.Input[str] instance_type: DB Instance type. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/26312.htm).
        :param pulumi.Input[str] maintain_time: Maintainable time period format of the instance: HH:MMZ-HH:MMZ (UTC time)
        :param pulumi.Input[float] monitoring_period: The monitoring frequency in seconds. Valid values are 5, 60, 300. Defaults to 300. 
        :param pulumi.Input[list] parameters: Set of parameters needs to be set after DB instance was launched. Available parameters can refer to the latest docs [View database parameter templates](https://www.alibabacloud.com/help/doc-detail/26284.htm) .
        :param pulumi.Input[float] period: The duration that you will buy DB instance (in month). It is valid when instance_charge_type is `PrePaid`. Valid values: [1~9], 12, 24, 36. Default to 1.
        :param pulumi.Input[str] port: RDS database connection port.
        :param pulumi.Input[str] security_group_id: It has been deprecated from 1.69.0 and use `security_group_ids` instead.
        :param pulumi.Input[list] security_group_ids: , Available in 1.69.0+) The list IDs to join ECS Security Group. At most supports three security groups.
        :param pulumi.Input[str] security_ip_mode: Valid values are `normal`, `safety`, Default to `normal`. support `safety` switch to high security access mode 
        :param pulumi.Input[list] security_ips: List of IP addresses allowed to access all databases of an instance. The list contains up to 1,000 IP addresses, separated by commas. Supported formats include 0.0.0.0/0, 10.23.12.24 (IP), and 10.23.12.24/24 (Classless Inter-Domain Routing (CIDR) mode. /24 represents the length of the prefix in an IP address. The range of the prefix length is [1,32]).
        :param pulumi.Input[float] sql_collector_config_value: The sql collector keep time of the instance. Valid values are `1`, `30`, `180`, `365`, `1095`, `1825`, `1` is the initial value, and can't change it to `1`.
        :param pulumi.Input[str] sql_collector_status: The sql collector status of the instance. Valid values are `Enabled`, `Disabled`, Default to `Disabled`.
        :param pulumi.Input[dict] tags: A mapping of tags to assign to the resource.
               - Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
               - Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
        :param pulumi.Input[str] vswitch_id: The virtual switch ID to launch DB instances in one VPC.
        :param pulumi.Input[str] zone_id: The Zone to launch the DB instance. From version 1.8.1, it supports multiple zone.
               If it is a multi-zone and `vswitch_id` is specified, the vswitch must in the one of them.
               The multiple zone ID can be retrieved by setting `multi` to "true" in the data source `.getZones`.
        
        The **parameters** object supports the following:
        
          * `name` (`pulumi.Input[str]`)
          * `value` (`pulumi.Input[str]`)

        > This content is derived from https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/website/docs/r/db_instance.html.markdown.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()
        __props__["auto_renew"] = auto_renew
        __props__["auto_renew_period"] = auto_renew_period
        __props__["auto_upgrade_minor_version"] = auto_upgrade_minor_version
        __props__["connection_string"] = connection_string
        __props__["db_instance_storage_type"] = db_instance_storage_type
        __props__["engine"] = engine
        __props__["engine_version"] = engine_version
        __props__["instance_charge_type"] = instance_charge_type
        __props__["instance_name"] = instance_name
        __props__["instance_storage"] = instance_storage
        __props__["instance_type"] = instance_type
        __props__["maintain_time"] = maintain_time
        __props__["monitoring_period"] = monitoring_period
        __props__["parameters"] = parameters
        __props__["period"] = period
        __props__["port"] = port
        __props__["security_group_id"] = security_group_id
        __props__["security_group_ids"] = security_group_ids
        __props__["security_ip_mode"] = security_ip_mode
        __props__["security_ips"] = security_ips
        __props__["sql_collector_config_value"] = sql_collector_config_value
        __props__["sql_collector_status"] = sql_collector_status
        __props__["tags"] = tags
        __props__["vswitch_id"] = vswitch_id
        __props__["zone_id"] = zone_id
        return Instance(resource_name, opts=opts, __props__=__props__)
    def translate_output_property(self, prop):
        return tables._CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop

    def translate_input_property(self, prop):
        return tables._SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop

