alicloud_gpdb_instance
Provides a AnalyticDB for PostgreSQL instance resource supports replica set instances only. the AnalyticDB for PostgreSQL provides stable, reliable, and automatic scalable database services. You can see the detail product introduction in the CreateDBInstance API reference.
-> NOTE: Available since v1.47.0.
-> NOTE: Destroying a Subscription instance fails with an error since v1.295.0. To destroy it, convert the instance to PayAsYouGo by setting payment_type = "PayAsYouGo" and re-applying, or unsubscribe it in the Alibaba Cloud console. To remove the instance from the state only, run terraform state rm.
Example Usage
Basic Usage
variable "name" {
default = "tf-example"
}
data "alicloud_resource_manager_resource_groups" "default" {
}
data "alicloud_gpdb_zones" "default" {
}
data "alicloud_vpcs" "default" {
# You need to modify name_regex to an existing VPC under your account
name_regex = "^default-NODELETING$"
}
data "alicloud_vswitches" "default" {
vpc_id = data.alicloud_vpcs.default.ids.0
zone_id = data.alicloud_gpdb_zones.default.ids.0
}
resource "alicloud_gpdb_instance" "default" {
db_instance_category = "HighAvailability"
db_instance_class = "gpdb.group.segsdx1"
db_instance_mode = "StorageElastic"
description = var.name
engine = "gpdb"
engine_version = "6.0"
zone_id = data.alicloud_gpdb_zones.default.ids.0
instance_network_type = "VPC"
instance_spec = "2C16G"
payment_type = "PayAsYouGo"
seg_storage_type = "cloud_essd"
seg_node_num = 4
storage_size = 50
vpc_id = data.alicloud_vpcs.default.ids.0
vswitch_id = data.alicloud_vswitches.default.ids.0
ip_whitelist {
security_ip_list = "127.0.0.1"
}
}
Need more examples? VIEW MORE EXAMPLES
Argument Reference
The following arguments are supported:
-
engine- (Required, ForceNew) The database engine used by the instance. Value options can refer to the latest docs CreateDBInstanceEngineVersion. -
engine_version- (Required, ForceNew) The version of the database engine used by the instance. -
minor_version- (Optional, Computed, Available since v1.287.0) The minor version of the instance. When this attribute is changed, the provider calls the UpgradeDBVersion operation to upgrade the minor version of the instance and waits until the upgrade is complete. The value must be a valid minor version of the instance's engine version.-> NOTE: The instance is created with the latest minor version, so this attribute does not take effect at creation time; it only triggers a minor version upgrade when it is changed after the instance is created. The current minor version of the instance is read back into state.
-
effective_time- (Optional, Available since v1.295.0) The effective time of an in-place upgrade task. It is sent with the UpgradeDBVersion and UpgradeDBInstance operations when one of the upgradable attributes (minor_version,seg_node_num,master_node_num,instance_spec,storage_size,serverless_resource,cache_storage_size,seg_disk_performance_level) is changed. Valid values:Immediate: The upgrade takes effect immediately. This is the API default when the attribute is not set.MaintainTime: The upgrade is scheduled into the maintenance window (configured viamaintain_start_timeandmaintain_end_time) and takes effect within it.
-> NOTE:
effective_timeis a per-operation modifier and is not an instance attribute, so it is not read back from the API. WhenMaintainTimeis used, the upgrade executes at the next maintenance window: until the upgrade task runs, the API keeps reporting the previous values of the upgraded attributes and the provider reports a plan diff for them. The provider does not wait for the value convergence in this case and returns after the upgrade request is accepted. -
vswitch_id- (Required, ForceNew) The vswitch id. -
db_instance_class- (Optional, ForceNew) The db instance class. see Instance specifications.-> NOTE: This parameter must be passed in to create a storage reservation mode instance.
-
db_instance_category- (Optional, ForceNew) The db instance category. Valid values:Basic,HighAvailability.-> NOTE: This parameter must be passed in to create a storage reservation mode instance.
-
db_instance_mode- (Required, ForceNew) The db instance mode. Valid values:StorageElastic,Serverless,Classic,ServerlessPro.-> NOTE:
ServerlessProis a dedicated Serverless Pro instance form. Whendb_instance_modeis set toServerlessPro, instance sizing is controlled viaserverless_resourceandcache_storage_sizeinstead ofinstance_spec. -
instance_spec- (Optional, Computed) The specification of segment nodes. Valid values:2C16G,4C32G,16C128G,2C8G,4C16G,8C32G,8C64G,16C64G,32C256G,64C512G,96C768G,128C1024G.- If
db_instance_categoryis set toHighAvailability, anddb_instance_modeis set toStorageElastic. Valid values:2C16G,4C32G,16C128G. - If
db_instance_categoryis set toBasic, anddb_instance_modeis set toStorageElastic. Valid values:2C8G,4C16G,8C32G,16C64G. - If
db_instance_modeis set toServerless. Valid values:4C16G,8C32G.
-> NOTE: This parameter must be passed to create a storage elastic mode instance and a serverless version instance.
-> NOTE: For
ServerlessProinstances,instance_specis a server-side placeholder (e.g.1C8G) returned by the API and is not user-configurable; sizing is controlled viaserverless_resourceandcache_storage_size. The placeholder is read into state but should not be set in the configuration. - If
-
storage_size- (Optional, Int) The storage capacity. Unit: GB. Valid values:50to4000.-> NOTE: This parameter must be passed in to create a storage reservation mode instance.
-
instance_network_type- (Optional, ForceNew) The network type of the instance. Valid values:VPC. -
vpc_id- (Optional, ForceNew) The vpc ID of the resource. -
zone_id- (Optional, ForceNew) The zone ID of the instance. -
instance_group_count- (Optional, ForceNew, Int) The number of nodes. Valid values:2,4,8,12,16,24,32,64,96,128. -
payment_type- (Optional) The billing method of the instance. Valid values:Subscription,PayAsYouGo. NOTE: From provider version 1.287.0,payment_typecan be modified in both directions betweenSubscriptionandPayAsYouGo. When modifying the billing method of an instance toSubscription,periodandused_timeare required; when modifying the billing method of an instance toPayAsYouGo,periodandused_timeare not required. See ModifyDBInstancePayType. -
period- (Optional) The duration that you will buy the resource, in month. required whenpayment_typeisSubscription, including whenpayment_typeis modified toSubscription. Valid values:Year,Month. -
resource_group_id- (Optional) The ID of the enterprise resource group to which the instance belongs. -
master_cu- (Optional, Int, Available since v1.213.0) The amount of coordinator node resources. Valid values:2,4,8,16,32. -
seg_node_num- (Optional, Int) Calculate the number of nodes. Valid values:2to512. The value range of the high-availability version of the storage elastic mode is4to512, and the value must be a multiple of4. The value range of the basic version of the storage elastic mode is2to512, and the value must be a multiple of2. The-Serverless version has a value range of2to512. The value must be a multiple of2.-> NOTE: This parameter must be passed in to create a storage elastic mode instance and a Serverless version instance. During the public beta of the Serverless version (from 0101, 2022 to 0131, 2022), a maximum of 12 compute nodes can be created.
-
seg_storage_type- (Optional, ForceNew) The seg storage type. Valid values:cloud_essd. NOTE: Ifdb_instance_modeis set toStorageElastic,seg_storage_typeis required. From version 1.233.1,seg_storage_typecannot be modified, or set tocloud_efficiency.seg_storage_typecan only be set tocloud_essd. -
seg_disk_performance_level- (Optional, Available since v1.233.1) The ESSD cloud disk performance level. Valid values:pl0,pl1,pl2. -
create_sample_data- (Optional, Bool) Whether to load the sample dataset after the instance is created. Valid values:true,false. -
ssl_enabled- (Optional, Int, Available since v1.188.0) Enable or disable SSL. Valid values:0and1. -
sql_collector_status- (Optional, Available since v1.295.0) Specifies whether to enable or disable SQL explorer (SQL collector). The provider calls the ModifySQLCollectorPolicy operation when this attribute is set or changed. Valid values:Enabled: Enables SQL collector.Disabled: Disables SQL collector.
-> NOTE: The ModifySQLCollectorPolicy operation is supported only by storage-reserved instances and the Serverless auto-scheduling version. Check the product documentation for the support scope of your instance mode.
-> NOTE: The GPDB API does not provide an operation to query the SQL collector status, so this attribute is write-only: it is not read back into state during
terraform refreshor import. Removing the attribute from the configuration does not disable SQL collector either: the provider does not call ModifySQLCollectorPolicy in that case, so the cloud-side status stays unchanged. Setsql_collector_status = "Disabled"explicitly to disable it. -
encryption_type- (Optional, ForceNew, Available since v1.207.2) The encryption type. Valid values:CloudDisk.-> NOTE: Disk encryption cannot be disabled after it is enabled.
-
encryption_key- (Optional, ForceNew, Available since v1.207.2) The ID of the encryption key.-> NOTE: If
encryption_typeis set toCloudDisk, you must specify an encryption key that resides in the same region as the cloud disk that is specified by EncryptionType. Otherwise, leave this parameter empty. -
vector_configuration_status- (Optional, Available since v1.207.2) Specifies whether to enable vector engine optimization. Default value:disabled. Valid values:enabledanddisabled. -
maintain_start_time- (Optional) The start time of the maintenance window for the instance. in the format of HH:mmZ (UTC time), for example 02:00Z. -
maintain_end_time- (Optional) The end time of the maintenance window for the instance. in the format of HH:mmZ (UTC time), for example 03:00Z. start time should be later than end time. -
resource_management_mode- (Optional, Available since v1.225.0) Resource management mode. Valid values:resourceGroup,resourceQueue. -
serverless_mode- (Optional, ForceNew, Available since v1.233.1) The mode of the Serverless instance. Valid values:Manual,Auto. NOTE:serverless_modeis valid only whendb_instance_modeis set toServerless. -
serverless_resource- (Optional, Int, Available since v1.287.0) The computing resource threshold, in ACU. Valid values:16to1024. NOTE:serverless_resourceis valid only whendb_instance_modeis set toServerlessPro. The value can be modified in place forServerlessProinstances. -
cache_storage_size- (Optional, Int, Available since v1.287.0) The cache storage size, in GB. Valid values:800to102400. NOTE:cache_storage_sizeis valid only whendb_instance_modeis set toServerlessPro. The value can be modified in place forServerlessProinstances. -
prod_type- (Optional, ForceNew, Available since v1.233.1) The type of the product. Default value:standard. Valid values:standard,cost-effective. -
data_share_status- (Optional, Available since v1.233.1) Specifies whether to enable or disable data sharing. Default value:closed. Valid values:opened: Enables data sharing.closed: Disables data sharing.
-> NOTE:
data_share_statusis valid only whendb_instance_modeis set toServerless. -
status- (Optional, Available since v1.288.0) The expected status of the instance. Valid values:Running: The instance is expected to be running. If the instance is paused, the provider resumes it.Stopped: The instance is expected to be stopped. If the instance is running, the provider pauses it.
When
statusis not set, it keeps the read-only behavior and the provider does not manage the instance status.-> NOTE: Setting
statusactually pauses or resumes the instance. Pausing or resuming an instance is supported only for Serverless instances with kernel version V1.0.2.1 or later, the instance must be charged with the PayAsYouGo billing method, and pausing takes effect only when the instance is in the running state. See PauseInstance and ResumeInstance.-> NOTE: Pausing or resuming an instance is asynchronous. While a pause or resume request is in progress, the status of the instance transitions through
STOPPINGorSTARTINGand then converges toSTOPPED(paused) orRunning(resumed).-> NOTE:
statusdoes not take part in the instance creation. A new instance is always created in the running state and is paused afterwards whenstatusis set toStopped. -
used_time- (Optional) The used time. When the parameterperiodisYear, theused_timevalue is1to3. When the parameterperiodisMonth, theused_timevalue is1to9. NOTE: From provider version 1.287.0,used_timeis required (together withperiod) whenpayment_typeis modified toSubscription. -
description- (Optional) The description of the instance. -
backup_id- (Optional, ForceNew, Available since v1.287.0) The ID of the backup set. If specified, the instance is created from the existing backup set. See CreateDBInstance. -
src_db_instance_name- (Optional, ForceNew, Available since v1.287.0) The source instance ID for creating an instance from a backup set. Must be set together withbackup_id; the GPDB CreateDBInstance API requiresSrcDbInstanceNameandBackupIdto be null or not null at the same time. See CreateDBInstance. -
tags- (Optional) A mapping of tags to assign to the resource. -
ip_whitelist- (Optional, Set, Available since v1.187.0) The ip whitelist. Seeip_whitelistbelow. Default to creating a whitelist group with the group name "default" and security_ip_list "127.0.0.1". -
parameters- (Optional, Set, Available since v1.231.0) The parameters. Seeparametersbelow. -
security_ip_list- (Optional, List, Deprecated since v1.187.0) Fieldsecurity_ip_listhas been deprecated from provider version 1.187.0. New fieldip_whitelistinstead. -
instance_charge_type- (Optional, ForceNew, Deprecated since v1.187.0) Fieldinstance_charge_typehas been deprecated from provider version 1.187.0. New fieldpayment_typeinstead. -
availability_zone- (Optional, ForceNew, Deprecated since v1.187.0) Fieldavailability_zonehas been deprecated from provider version 1.187.0. New fieldzone_idinstead. -
master_node_num- (Optional, Int, Deprecated since v1.213.0) The number of Master nodes. NOTE: Fieldmaster_node_numhas been deprecated from provider version 1.213.0. -
private_ip_address- (Optional, Deprecated since v1.213.0) The private ip address. NOTE: Fieldprivate_ip_addresshas been deprecated from provider version 1.213.0.
ip_whitelist
The ip_whitelist supports the following:
ip_group_attribute- (Optional) The value of this parameter is empty by default. The attribute of the whitelist group. If the value containshidden, this white list item will not output.ip_group_name- (Optional) IP whitelist group name. Defaults todefault, the built-in whitelist group; a group without a name is applied to thedefaultgroup instead of creating a new one.security_ip_list- (Optional) 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]). System default to["127.0.0.1"].
parameters
The parameters supports the following:
name- (Required, Available since v1.231.0) The name of the parameter.value- (Required, Available since v1.231.0) The value of the parameter.default_value- (Available since v1.231.0) The default value of the parameter.is_changeable_config- (Available since v1.231.0) Whether the parameter is changeable.force_restart_instance- (Available since v1.231.0) Whether to force restart the instance to config the parameter.optional_range- (Available since v1.231.0) The optional range of the parameter.parameter_description- (Available since v1.231.0) The description of the parameter.
Attributes Reference
The following attributes are exported:
id- The resource ID in terraform of AnalyticDB for PostgreSQL.connection_string- (Available since v1.196.0) The connection string of the instance.port- (Available since v1.196.0) The connection port of the instance.
Timeouts
The timeouts block allows you to specify timeouts for certain actions:
create- (Defaults to 60 mins) Used when create the DB Instance.update- (Defaults to 60 mins) Used when update the DB Instance.delete- (Defaults to 10 mins) Used when update the DB Instance.
Import
AnalyticDB for PostgreSQL can be imported using the id, e.g.
$ terraform import alicloud_gpdb_instance.example <id>