全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

ksyun_krds

最近更新时间:2022-02-08 11:55:08

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.

Example Usage

»Create a RDS MySQL instance

provider "ksyun"{
  region = "cn-shanghai-3"
  access_key = ""
  secret_key = ""
}

variable "available_zone" {
  default = "cn-shanghai-3a"
}
resource "ksyun_vpc" "default" {
  vpc_name   = "ksyun-vpc-tf"
  cidr_block = "10.7.0.0/21"
}
resource "ksyun_subnet" "foo" {
  subnet_name      = "ksyun-subnet-tf"
  cidr_block = "10.7.0.0/21"
  subnet_type = "Reserve"
  dhcp_ip_from = "10.7.0.2"
  dhcp_ip_to = "10.7.0.253"
  vpc_id  = "${ksyun_vpc.default.id}"
  gateway_ip = "10.7.0.1"
  dns1 = "198.18.254.41"
  dns2 = "198.18.254.40"
  availability_zone = "${var.available_zone}"
}

resource "ksyun_krds_security_group" "krds_sec_group_14" {
  output_file = "output_file"
  security_group_name = "terraform_security_group_14"
  security_group_description = "terraform-security-group-14"
  security_group_rule{
    security_group_rule_protocol = "182.133.0.0/16"
    security_group_rule_name = "asdf"
  }
  security_group_rule{
    security_group_rule_protocol = "182.134.0.0/16"
    security_group_rule_name = "asdf2"
  }
}

resource "ksyun_krds" "my_rds_xx"{
  output_file = "output_file"
  db_instance_class= "db.ram.2|db.disk.21"
  db_instance_name = "houbin_terraform_1-n"
  db_instance_type = "HRDS"
  engine = "mysql"
  engine_version = "5.7"
  master_user_name = "admin"
  master_user_password = "123qweASD123"
  vpc_id = "${ksyun_vpc.default.id}"
  subnet_id = "${ksyun_subnet.foo.id}"
  bill_type = "DAY"
  security_group_id = "${ksyun_krds_security_group.krds_sec_group_14.id}"
  preferred_backup_time = "01:00-02:00"
  availability_zone_1 = "cn-shanghai-3a"
  availability_zone_2 = "cn-shanghai-3b"
}

»Create a RDS MySQL instance with specific parameters

provider "ksyun"{
  region = "cn-shanghai-3"
  access_key = ""
  secret_key = ""
}

variable "available_zone" {
  default = "cn-shanghai-3a"
}
resource "ksyun_vpc" "default" {
  vpc_name   = "ksyun-vpc-tf"
  cidr_block = "10.7.0.0/21"
}
resource "ksyun_subnet" "foo" {
  subnet_name      = "ksyun-subnet-tf"
  cidr_block = "10.7.0.0/21"
  subnet_type = "Reserve"
  dhcp_ip_from = "10.7.0.2"
  dhcp_ip_to = "10.7.0.253"
  vpc_id  = "${ksyun_vpc.default.id}"
  gateway_ip = "10.7.0.1"
  dns1 = "198.18.254.41"
  dns2 = "198.18.254.40"
  availability_zone = "${var.available_zone}"
}

resource "ksyun_krds_security_group" "krds_sec_group_14" {
  output_file = "output_file"
  security_group_name = "terraform_security_group_14"
  security_group_description = "terraform-security-group-14"
  security_group_rule{
    security_group_rule_protocol = "182.133.0.0/16"
    security_group_rule_name = "asdf"
  }
  security_group_rule{
    security_group_rule_protocol = "182.134.0.0/16"
    security_group_rule_name = "asdf2"
  }
}

resource "ksyun_krds" "my_rds_xx"{
  output_file = "output_file"
  db_instance_class= "db.ram.2|db.disk.21"
  db_instance_name = "houbin_terraform_1-n"
  db_instance_type = "HRDS"
  engine = "mysql"
  engine_version = "5.7"
  master_user_name = "admin"
  master_user_password = "123qweASD123"
  vpc_id = "${ksyun_vpc.default.id}"
  subnet_id = "${ksyun_subnet.foo.id}"
  bill_type = "DAY"
  security_group_id = "${ksyun_krds_security_group.krds_sec_group_14.id}"
  preferred_backup_time = "01:00-02:00"
  parameters {
    name = "auto_increment_increment"
    value = "8"
  }

  parameters {
    name = "binlog_format"
    value = "ROW"
  }

  parameters {
    name = "delayed_insert_limit"
    value = "108"
  }
  parameters {
    name = "auto_increment_offset"
    value= "2"
  }
  availability_zone_1 = "cn-shanghai-3a"
  availability_zone_2 = "cn-shanghai-3b"
  instance_has_eip = true
}

Argument Reference

The following arguments are supported:

  • output_file -(Required) will return the file name of the content store
  • db_instance_class-(Required)-this value regex db.ram.d{1,3}|db.disk.d{1,5} , db.ram is rds random access memory size, db.disk is disk size
  • db_instance_name-(Required)instance name
  • db_instance_type- (Required)instance type supports hrds
  • engine-(Required)-engine is db type, only support mysql|percona
  • engine_version- (Required) database engine version. Only upgrade version is supported when modifying
    db engine version only support 5.5|5.6|5.7|8.0
  • master_user_name- (Required)database primary account name
  • master_user_password-(Required) master account password
  • vpc_id- (Required)ID of virtual private network
  • subnet_id- (Required)subnet ID
  • bill_type- (Required) Bill type, YEAR_MONTH (monthly package), DAY (daily billing), default: YEAR_MONTH
  • duration- (Optional) purchase duration in months
  • security_group_id-(Optional) security group ID
  • preferred_backup_time- (Optional) backup time
  • availability_zone_1- (Optional) zone 1
  • availability_zone_2- (Optional) zone 2
  • project_id- (Optional) subproject ID
  • parameters- (Optional) database parameters
  • port-(Optional) port number
  • instance_has_eip -(Optional) attach eip for instance

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • DBInstanceClass- instance specification
  • Vcpus- number of CPUs
  • Disk- hard disk size
  • Ram- memory size
  • DBInstanceIdentifier- instance ID
  • DBInstanceName- instance name
  • DBInstanceStatus- instance status
  • DBInstanceType- instance type
  • DBParameterGroupId- parameter group ID
  • GroupId- group ID
  • SecurityGroupId- security group ID
  • Vip- virtual IP
  • Port- port number
  • Engine- Database Engine
  • EngineVersion- database engine version
  • InstanceCreateTime- instance creation time
  • MasterUserName- primary account user name
  • DatastoreVersionId- database version
  • Region- region
  • VpcId-virtual private network ID
  • ReadReplicaDBInstanceIdentifiers- read only instance
  • BillType- Bill type
  • MultiAvailabilityZone- Multi availability zone
  • ProductId- Product ID
  • DiskUsed- hard disk usage
  • ProjectId- Project ID

NOTE: Because of data backup and migration, change DB instance type and storage would cost 15~30 minutes, or even more. Please make full preparation before changing them.

»Attributes Reference
The following attributes are exported:

id - The RDS instance ID.
port - RDS database connection port.

»Timeouts
NOTE: Available in 1.52.1+.

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

create - (Defaults to 30 mins) Used when creating the db instance (until it reaches the initial Running status).
update - (Defaults to 30 mins) Used when updating the db instance (until it reaches the initial Running status).
delete - (Defaults to 10 mins) Used when terminating the db instance
文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容
文档反馈