Skip to content

Commit

Permalink
add changelog and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
lyu571 committed Jun 27, 2023
1 parent 0ce8693 commit f5e34e7
Show file tree
Hide file tree
Showing 3 changed files with 216 additions and 20 deletions.
99 changes: 95 additions & 4 deletions tencentcloud/resource_tc_cynosdb_cluster_slave_zone.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,103 @@
/*
Provides a resource to create a cynosdb cluster_slave_zone
Provides a resource to create a cynosdb cluster slave zone.
Example Usage
Set a new slave zone for a cynosdb cluster.
```hcl
locals {
vpc_id = data.tencentcloud_vpc_subnets.gz3.instance_list.0.vpc_id
subnet_id = data.tencentcloud_vpc_subnets.gz3.instance_list.0.subnet_id
sg_id = data.tencentcloud_security_groups.internal.security_groups.0.security_group_id
sg_id2 = data.tencentcloud_security_groups.exclusive.security_groups.0.security_group_id
}
variable "fixed_tags" {
default = {
fixed_resource: "do_not_remove"
}
}
variable "availability_zone" {
default = "ap-guangzhou-4"
}
variable "new_availability_zone" {
default = "ap-guangzhou-6"
}
variable "my_param_template" {
default = "15765"
}
data "tencentcloud_security_groups" "internal" {
name = "default"
tags = var.fixed_tags
}
data "tencentcloud_security_groups" "exclusive" {
name = "test_preset_sg"
}
data "tencentcloud_vpc_subnets" "gz3" {
availability_zone = var.default_az
is_default = true
}
resource "tencentcloud_cynosdb_cluster" "instance" {
available_zone = var.availability_zone
vpc_id = local.vpc_id
subnet_id = local.subnet_id
db_type = "MYSQL"
db_version = "5.7"
storage_limit = 1000
cluster_name = "tf_test_cynosdb_cluster_slave_zone"
password = "cynos@123"
instance_maintain_duration = 3600
instance_maintain_start_time = 10800
instance_maintain_weekdays = [
"Fri",
"Mon",
"Sat",
"Sun",
"Thu",
"Wed",
"Tue",
]
instance_cpu_core = 1
instance_memory_size = 2
param_items {
name = "character_set_server"
current_value = "utf8"
}
param_items {
name = "time_zone"
current_value = "+09:00"
}
force_delete = true
rw_group_sg = [
local.sg_id
]
ro_group_sg = [
local.sg_id
]
prarm_template_id = var.my_param_template
}
resource "tencentcloud_cynosdb_cluster_slave_zone" "cluster_slave_zone" {
cluster_id = tencentcloud_cynosdb_cluster.instance.id
slave_zone = var.new_availability_zone
}
```
Update the slave zone with specified value.
```
resource "tencentcloud_cynosdb_cluster_slave_zone" "cluster_slave_zone" {
cluster_id = "cynosdbmysql-xxxxxxxx"
slave_zone = "ap-guangzhou-3"
cluster_id = tencentcloud_cynosdb_cluster.instance.id
slave_zone = var.availability_zone
}
```
Expand All @@ -15,7 +106,7 @@ Import
cynosdb cluster_slave_zone can be imported using the id, e.g.
```
terraform import tencentcloud_cynosdb_cluster_slave_zone.cluster_slave_zone cluster_slave_zone_id
terraform import tencentcloud_cynosdb_cluster_slave_zone.cluster_slave_zone cluster_id#slave_zone
```
*/
package tencentcloud
Expand Down
34 changes: 23 additions & 11 deletions tencentcloud/resource_tc_cynosdb_cluster_slave_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,27 @@ func TestAccTencentCloudCynosdbClusterSlaveZoneResource_basic(t *testing.T) {
})
}

const testAccCynosdbClusterSlaveZone_instance = testAccCynosdbBasic + `
resource "tencentcloud_cynosdb_cluster" "foo" {
const testAccCynosdbClusterSlaveZone_instance = defaultSecurityGroupData + defaultVpcSubnets + `
variable "availability_zone" {
default = "ap-guangzhou-4"
}
variable "new_availability_zone" {
default = "ap-guangzhou-6"
}
variable "my_param_template" {
default = "15765"
}
resource "tencentcloud_cynosdb_cluster" "instance" {
available_zone = var.availability_zone
vpc_id = var.my_vpc
subnet_id = var.my_subnet
vpc_id = local.vpc_id
subnet_id = local.subnet_id
db_type = "MYSQL"
db_version = "5.7"
storage_limit = 1000
cluster_name = "tf-cynosdb-salve-zone"
cluster_name = "tf_test_cynosdb_cluster_slave_zone"
password = "cynos@123"
instance_maintain_duration = 3600
instance_maintain_start_time = 10800
Expand All @@ -64,11 +76,11 @@ resource "tencentcloud_cynosdb_cluster" "foo" {
instance_cpu_core = 1
instance_memory_size = 2
param_items {
name = "character_set_server"
name = "character_set_server"
current_value = "utf8"
}
param_items {
name = "time_zone"
name = "time_zone"
current_value = "+09:00"
}
Expand All @@ -87,17 +99,17 @@ resource "tencentcloud_cynosdb_cluster" "foo" {
const testAccCynosdbClusterSlaveZone = testAccCynosdbClusterSlaveZone_instance + `
resource "tencentcloud_cynosdb_cluster_slave_zone" "cluster_slave_zone" {
cluster_id = tencentcloud_cynosdb_cluster.foo.id
slave_zone = "ap-guangzhou-6"
cluster_id = tencentcloud_cynosdb_cluster.instance.id
slave_zone = var.new_availability_zone
}
`

const testAccCynosdbClusterSlaveZone_update = testAccCynosdbClusterSlaveZone_instance + `
resource "tencentcloud_cynosdb_cluster_slave_zone" "cluster_slave_zone" {
cluster_id = tencentcloud_cynosdb_cluster.foo.id
slave_zone = "ap-guangzhou-4"
cluster_id = tencentcloud_cynosdb_cluster.instance.id
slave_zone = var.availability_zone
}
`
103 changes: 98 additions & 5 deletions website/docs/r/cynosdb_cluster_slave_zone.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,112 @@ layout: "tencentcloud"
page_title: "TencentCloud: tencentcloud_cynosdb_cluster_slave_zone"
sidebar_current: "docs-tencentcloud-resource-cynosdb_cluster_slave_zone"
description: |-
Provides a resource to create a cynosdb cluster_slave_zone
Provides a resource to create a cynosdb cluster slave zone.
---

# tencentcloud_cynosdb_cluster_slave_zone

Provides a resource to create a cynosdb cluster_slave_zone
Provides a resource to create a cynosdb cluster slave zone.

## Example Usage

Set a new slave zone for a cynosdb cluster.

```hcl
locals {
vpc_id = data.tencentcloud_vpc_subnets.gz3.instance_list.0.vpc_id
subnet_id = data.tencentcloud_vpc_subnets.gz3.instance_list.0.subnet_id
sg_id = data.tencentcloud_security_groups.internal.security_groups.0.security_group_id
sg_id2 = data.tencentcloud_security_groups.exclusive.security_groups.0.security_group_id
}
variable "fixed_tags" {
default = {
fixed_resource : "do_not_remove"
}
}
variable "availability_zone" {
default = "ap-guangzhou-4"
}
variable "new_availability_zone" {
default = "ap-guangzhou-6"
}
variable "my_param_template" {
default = "15765"
}
data "tencentcloud_security_groups" "internal" {
name = "default"
tags = var.fixed_tags
}
data "tencentcloud_security_groups" "exclusive" {
name = "test_preset_sg"
}
data "tencentcloud_vpc_subnets" "gz3" {
availability_zone = var.default_az
is_default = true
}
resource "tencentcloud_cynosdb_cluster" "instance" {
available_zone = var.availability_zone
vpc_id = local.vpc_id
subnet_id = local.subnet_id
db_type = "MYSQL"
db_version = "5.7"
storage_limit = 1000
cluster_name = "tf_test_cynosdb_cluster_slave_zone"
password = "cynos@123"
instance_maintain_duration = 3600
instance_maintain_start_time = 10800
instance_maintain_weekdays = [
"Fri",
"Mon",
"Sat",
"Sun",
"Thu",
"Wed",
"Tue",
]
instance_cpu_core = 1
instance_memory_size = 2
param_items {
name = "character_set_server"
current_value = "utf8"
}
param_items {
name = "time_zone"
current_value = "+09:00"
}
force_delete = true
rw_group_sg = [
local.sg_id
]
ro_group_sg = [
local.sg_id
]
prarm_template_id = var.my_param_template
}
resource "tencentcloud_cynosdb_cluster_slave_zone" "cluster_slave_zone" {
cluster_id = tencentcloud_cynosdb_cluster.instance.id
slave_zone = var.new_availability_zone
}
```

Update the slave zone with specified value.

```hcl
resource "tencentcloud_cynosdb_cluster_slave_zone" "cluster_slave_zone" {
cluster_id = "cynosdbmysql-xxxxxxxx"
slave_zone = "ap-guangzhou-3"
cluster_id = tencentcloud_cynosdb_cluster.instance.id
slave_zone = var.availability_zone
}
```

Expand All @@ -40,6 +133,6 @@ In addition to all arguments above, the following attributes are exported:
cynosdb cluster_slave_zone can be imported using the id, e.g.

```
terraform import tencentcloud_cynosdb_cluster_slave_zone.cluster_slave_zone cluster_slave_zone_id
terraform import tencentcloud_cynosdb_cluster_slave_zone.cluster_slave_zone cluster_id#slave_zone
```

0 comments on commit f5e34e7

Please sign in to comment.