» alicloud_polardb_cluster

Provides a PolarDB cluster resource. A PolarDB cluster is an isolated database environment in the cloud. A PolarDB cluster can contain multiple user-created databases.

» Example Usage

» Create a PolarDB MySQL cluster

variable "name" {
  default = "polardbClusterconfig"
variable "creation" {
  default = "PolarDB"
data "alicloud_zones" "default" {
  available_resource_creation = "${var.creation}"
resource "alicloud_vpc" "default" {
  name       = "${var.name}"
  cidr_block = ""
resource "alicloud_vswitch" "default" {
  vpc_id            = "${alicloud_vpc.default.id}"
  cidr_block        = ""
  availability_zone = "${data.alicloud_zones.default.zones.0.id}"
  name              = "${var.name}"
resource "alicloud_polardb_cluster" "default" {
  db_type               = "MySQL"
  db_version            = "5.6"
  db_node_class         = "rds.mysql.s2.large"
  pay_type              = "PostPaid"
  description           = "${var.name}"
  vswitch_id            = "${alicloud_vswitch.default.id}"

» Argument Reference

The following arguments are supported:

  • db_type - (Required,ForceNew) Database type. Value options: MySQL, Oracle, PostgreSQL.
  • db_version - (Required,ForceNew) Database version. Value options can refer to the latest docs CreateDBCluster DBVersion.
  • db_node_class - (Required) The db_node_class of cluster node.
  • modify_type - (Optional, Available in 1.71.2+) Use as db_node_class change class , define upgrade or downgrade. Valid values are Upgrade, Downgrade, Default to Upgrade.
  • zone_id - (Optional) The Zone to launch the DB cluster. it supports multiple zone.
  • pay_type - (Optional,ForceNew) Valid values are PrePaid, PostPaid, Default to PostPaid. Currently, the resource can not supports change pay type.
  • renewal_status - (Optional) Valid values are AutoRenewal, Normal, NotRenewal, Default to NotRenewal.
  • auto_renew_period - (Optional) Auto-renewal period of an cluster, in the unit of the month. It is valid when pay_type is PrePaid. Valid value:1, 2, 3, 6, 12, 24, 36, Default to 1.
  • period - (Optional) The duration that you will buy DB cluster (in month). It is valid when pay_type is PrePaid. Valid values: [1~9], 12, 24, 36. Default to 1.
  • security_ips - (Optional) List of IP addresses allowed to access all databases of an cluster. The list contains up to 1,000 IP addresses, separated by commas. Supported formats include, (IP), and (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]).
  • vswitch_id - (Optional) The virtual switch ID to launch DB instances in one VPC.
  • maintain_time - (Optional) Maintainable time period format of the instance: HH:MMZ-HH:MMZ (UTC time)
  • description - (Optional) The description of cluster.
  • parameters - (Optional) Set of parameters needs to be set after DB cluster was launched. Available parameters can refer to the latest docs View database parameter templates .
  • tags - (Optional, Available in v1.68.0+) 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.

» Removing alicloud_polardb_cluster from your configuration

The alicloud_polardb_cluster resource allows you to manage your polardb cluster, but Terraform cannot destroy it if your cluster type is pre paid(post paid type can destroy normally). Removing this resource from your configuration will remove it from your statefile and management, but will not destroy the cluster. You can resume managing the cluster via the polardb Console.

» Attributes Reference

The following attributes are exported:

  • id - The PolarDB cluster ID.
  • connection_string - (Available in 1.81.0+) PolarDB cluster connection string. When security_ips is configured, the address of cluster type endpoint will be returned, and if only "" is configured, it will also be an empty string.

» Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 mins) Used when creating the polardb cluster (until it reaches the initial Running status).
  • update - (Defaults to 30 mins) Used when updating the polardb cluster (until it reaches the initial Running status).
  • delete - (Defaults to 10 mins) Used when terminating the polardb cluster.

» Import

PolarDB cluster can be imported using the id, e.g.

$ terraform import alicloud_polardb_cluster.example pc-abc12345678