全部文档
当前文档

暂无内容

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

文档中心

terraform-ksyun

最近更新时间:2021-01-06 18:25:30

资源 resource
ksyun_krds
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.
提供RDS实例资源。 数据库实例是云中的隔离数据库环境。 一个数据库实例可以包含多个用户创建的数据库。

使用案例

»Create a RDS MySQL instance
创建一个RDS实例
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
创建一个带有明确参数的RDS实例
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"
}

Argument Reference

The following arguments are supported:
支持下列参数

  • output_file (Required) 将返回内容存储的文件名
  • db_instance_class(Required)数据库规格,
  • 正则格式为 db.ram.d{1,3}|db.disk.d{1,5},
  • db.ram表示实例的运行内存大小,db.disk表示运行硬盘大小
-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)实例名称
db_instance_type (Required)实例类型支持HRDS
engine (Required)数据库引擎名称mysql|percona
-engine is db type, only support mysql|percona
engine_version (Required)数据库引擎版本,修改时只支持升级版本
db engine version only support 5.5|5.6|5.7|8.0
master_user_name (Required)数据库主账号名称
master_user_password (Required)主账号密码
vpc_id (Required)虚拟私有网络的id
subnet_id (Required)子网id
bill_type (Required)账单类型,
YEAR_MONTH(包年包月),
DAY(按日计费),默认值:YEAR_MONTH
duration (Optional) 购买时长,以月为单位
security_group_id (Optional) 安全组id
preferred_backup_time (Optional) 备份时间
availability_zone_1 (Optional) 可用区1
availability_zone_2 (Optional) 可用区2
project_id (Optional) 子项目id
parameters (Optional) 数据库参数
port (Optional) 端口号

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.



ksyun_krds_rr
Provides an RDS Read Only instance resource. A DB read only instance is an isolated database environment in the cloud. 
提供RDS只读实例资源。 数据库只读实例是云中的隔离数据库环境。 
»使用案例
»Create a RDS RR MySQL instance
resource "ksyun_krds_rr" "my_rds_rr"{
  output_file = "output_file"
  db_instance_identifier= "******"
  db_instance_class= "db.ram.2|db.disk.50"
  db_instance_name = "houbin_terraform_888_rr_1"
  bill_type = "DAY"
  security_group_id = "******"

  parameters {
    name = "auto_increment_increment"
    value = "7"
  }

  parameters {
    name = "binlog_format"
    value = "ROW"
  }
}
»Argument Reference

The following arguments are supported:
支持下列参数
output_file (Required) 将返回内容存储的文件名
db_instance_identifier (Required) 传入RDS 高可用实例的实例id,一个RDS高可用实例最多3个只读实例
db_instance_class(Required)数据库规格,正则格式为 db.ram.d{1,3}|db.disk.d{1,5},db.ram表示实例的运行内存大小,db.disk表示运行硬盘大小,只读实例的规格不能小于高可用实例的规格
-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)实例名称
bill_type (Required)账单类型,YEAR_MONTH(包年包月),DAY(按日计费),默认值:YEAR_MONTH
duration (Optional) 购买时长,以月为单位
security_group_id (Optional) 安全组id
project_id (Optional) 子项目id
parameters (Optional) 数据库参数

NOTE:RDS RR do not support modify
RDS只读实例只支持创建和删除

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


ksyun_sqlserver
Provides an SqlServer instance resource. A DB instance is an isolated database environment in the cloud. A DB instance can contain multiple user-created databases.
提供SqlServer 实例资源。 SqlServer 数据库实例是云中的隔离数据库环境。 一个数据库实例可以包含多个用户创建的数据库。
»使用案例

»Create a RDS MySQL instance
创建一个RDS实例
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_sqlserver" "sqlserver-1"{
  output_file = "output_file"
  dbinstanceclass= "db.ram.2|db.disk.20"
  dbinstancename = "ksyun_sqlserver_1"
  dbinstancetype = "HRDS_SS"
  engine = "SQLServer"
  engineversion = "2008r2"
  masterusername = "admin"
  masteruserpassword = "123qweASD"
  vpc_id = "${ksyun_vpc.default.id}"
  subnet_id = "${ksyun_subnet.foo.id}"
  billtype = "DAY"
}
»Argument Reference

The following arguments are supported:
支持下列参数
output_file (Required) 将返回内容存储的文件名
db_instance_class(Required)数据库规格,正则格式为 db.ram.d{1,3}|db.disk.d{1,5},db.ram表示实例的运行内存大小,db.disk表示运行硬盘大小
-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)实例名称
db_instance_type (Required)实例类型支持HRDS_SS
engine (Required)数据库引擎名称SQLServer
-engine is db type, only support SQLServer
engine_version (Required)数据库引擎版本
db engine version only support 2008r2,2012,2016
master_user_name (Required)数据库主账号名称
master_user_password (Required)主账号密码
vpc_id (Required)虚拟私有网络的id
subnet_id (Required)子网id
bill_type (Required)账单类型,,YEAR_MONTH(包年包月),DAY(按日计费),默认值:YEAR_MONTH
duration (Optional) 购买时长,以月为单位
security_group_id (Optional) 安全组id
preferred_backup_time (Optional) 备份时间
project_id (Optional) 子项目id
parameters (Optional) 数据库参数
port (Optional) 端口号

NOTE: SQLServer not support modify
SQLServer 暂时不支持修改

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


ksyun_krds_security_group
提供RDS安全组功能
»使用案例

»Create a RDS Security Group instance
resource "ksyun_krds_security_group" "krds_sec_group_13" {
  output_file = "output_file"
  security_group_name = "terraform_security_group_13"
  security_group_description = "terraform-security-group-13"
  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"
  }

}

»Argument Reference

The following arguments are supported:
支持下列参数
output_file (Required) 将返回内容存储的文件名
security_group_name (Required)
security_group_description(Optional)

security_group_rule (Optional)安全组规则
–security_group_rule_protocol (Required) 0.0.0.0/32格式
–security_group_rule_name (Required)不超过256个字节,仅支持中文、大小写字母、数字、减号和下划线

»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 10 mins) Used when creating the db instance (until it reaches the initial Running status).
update - (Defaults to 10 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.

数据查询资源 data source
ksyun_krds
通过ksyun_krds查询HRDS、RDS-RR

data “ksyun_krds” “search-krds”{
output_file = “output_file”
db_instance_identifier = “***”
db_instance_type = “HRDS,RR,TRDS”
keyword = “”
order = “”
project_id = “”
marker = “”
max_records = “”
}

output_file (Required)将返回内容存储的文件名
db_instance_identifier (Optional)实例ID(传入实例ID,获取的是该实例的详情,否则则获取list)
db_instance_type (Optional)HRDS(高可用),RR(只读实例),TRDS(临时实例)
db_instance_status (Optional)ACTIVE(运行中)/INVALID(请续费)
keyword(Optional)按名称/VIP模糊过滤
order (Optional)区分大小写,取值范围:DEFAULT(默认排序方式),GROUP(按复制组排序,会把只读实例排在所属主实例的后面)
project_id (Optional) 默认值为所有项目
Marker(Optional)记录开始偏移量
MaxRecords(Optional)每页结果中包含的最大条数 取值范围:1-100

ksyun_sqlservers
通过ksyun_sqlservers查询HRDS-SS

data “ksyun_sqlservers” “search-sqlservers”{
output_file = “output_file”
db_instance_identifier = “***”
db_instance_type = “HRDS-SS”
keyword = “”
order = “”
project_id = “”
marker = “”
max_records = “”
}

output_file (Required)将返回内容存储的文件名
db_instance_identifier (Optional)实例ID(传入实例ID,获取的是该实例的详情,否则则获取list)
db_instance_type (Optional)HRDS(高可用),RR(只读实例),TRDS(临时实例)
db_instance_status (Optional)ACTIVE(运行中)/INVALID(请续费)
keyword(Optional)按名称/VIP模糊过滤
order (Optional)区分大小写,取值范围:DEFAULT(默认排序方式),GROUP(按复制组排序,会把只读实例排在所属主实例的后面)
project_id (Optional) 默认值为所有项目
Marker(Optional)记录开始偏移量
MaxRecords(Optional)每页结果中包含的最大条数 取值范围:1-100

ksyun_krds_security_groups
通过ksyun_krds_security_groups查询安全组

data “ksyun_sqlservers” “search-sqlservers”{
output_file = “output_file”
security_group_id = 123
}

output_file (Required)将返回内容存储的文件名
security_group_id (Optional)安全组id

文档导读
纯净模式常规模式

纯净模式

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