» 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 = "172.16.0.0/16"
}
resource "alicloud_vswitch" "default" {
  vpc_id            = "${alicloud_vpc.default.id}"
  cidr_block        = "172.16.0.0/24"
  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,ForceNew) The db_node_class of cluster node.
  • 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 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]).
  • vswitch_id - (Optional,ForceNew) 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.

» 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 20 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