Skip to content

Commit c6d3c3b

Browse files
authored
fix(cynosdb): [127578238] tencentcloud_cynosdb_cluster support instance_count params (#3525)
* add * add * add
1 parent 5daa05e commit c6d3c3b

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

.changelog/3525.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_cynosdb_cluster: support `instance_count` params
3+
```

tencentcloud/services/cynosdb/extension_cynosdb.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const (
1212
CYNOSDB_CHARGE_TYPE_POSTPAID = svcpostgresql.COMMON_PAYTYPE_POSTPAID
1313
CYNOSDB_CHARGE_TYPE_PREPAID = svcpostgresql.COMMON_PAYTYPE_PREPAID
1414
CYNOSDB_SERVERLESS = "SERVERLESS"
15+
CYNOSDB_NORMAL = "NORMAL"
1516

1617
CYNOSDB_STATUS_RUNNING = "running"
1718
CYNOSDB_STATUS_OFFLINE = "offlined"
@@ -185,6 +186,13 @@ func TencentCynosdbClusterBaseInfo() map[string]*schema.Schema {
185186
Sensitive: true,
186187
Description: "Password of `root` account.",
187188
},
189+
"instance_count": {
190+
Type: schema.TypeInt,
191+
Optional: true,
192+
ForceNew: true,
193+
Computed: true,
194+
Description: "The number of instances, the range is (0,16], the default value is 2 (i.e. one RW instance + one Ro instance), the passed n means 1 RW instance + n-1 Ro instances (with the same specifications), if you need a more accurate cluster composition, please use InstanceInitInfos.",
195+
},
188196
// payment
189197
"charge_type": {
190198
Type: schema.TypeString,

tencentcloud/services/cynosdb/resource_tc_cynosdb_cluster.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ func resourceTencentCloudCynosdbClusterCreate(d *schema.ResourceData, meta inter
9595
request.SlaveZone = helper.String(v.(string))
9696
}
9797

98+
if v, ok := d.GetOkExists("instance_count"); ok {
99+
request.InstanceCount = helper.IntInt64(v.(int))
100+
}
101+
98102
// set params
99103
if v, ok := d.GetOk("param_items"); ok {
100104
paramItems := v.([]interface{})
@@ -432,10 +436,14 @@ func resourceTencentCloudCynosdbClusterRead(d *schema.ResourceData, meta interfa
432436
_ = d.Set("serverless_status_flag", status)
433437
}
434438

435-
if _, ok := d.GetOk("db_mode"); ok || *item.DbMode == CYNOSDB_SERVERLESS {
439+
if _, ok := d.GetOk("db_mode"); ok || *item.DbMode == CYNOSDB_SERVERLESS || *item.DbMode == CYNOSDB_NORMAL {
436440
_ = d.Set("db_mode", item.DbMode)
437441
}
438442

443+
if item.InstanceNum != nil {
444+
_ = d.Set("instance_count", item.InstanceNum)
445+
}
446+
439447
//tag
440448
tagService := svctag.NewTagService(client)
441449
tags, err := tagService.DescribeResourceTags(ctx, "cynosdb", "instance", client.Region, id)

tencentcloud/services/cynosdb/resource_tc_cynosdb_cluster.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Provide a resource to create a CynosDB cluster.
22

3+
~> **NOTE:** params `instance_count` and `instance_init_infos` only choose one. If neither parameter is set, the CynosDB cluster is created with parameter `instance_count` set to `2` by default(one RW instance + one Ro instance). If you only need to create a master instance, explicitly set the `instance_count` field to `1`, or configure the RW instance information in the `instance_init_infos` field.
4+
35
Example Usage
46

57
Create a single availability zone NORMAL CynosDB cluster

website/docs/r/cynosdb_cluster.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: |-
1111

1212
Provide a resource to create a CynosDB cluster.
1313

14+
~> **NOTE:** params `instance_count` and `instance_init_infos` only choose one. If neither parameter is set, the CynosDB cluster is created with parameter `instance_count` set to `2` by default(one RW instance + one Ro instance). If you only need to create a master instance, explicitly set the `instance_count` field to `1`, or configure the RW instance information in the `instance_init_infos` field.
15+
1416
## Example Usage
1517

1618
### Create a single availability zone NORMAL CynosDB cluster
@@ -222,6 +224,7 @@ The following arguments are supported:
222224
* `cynos_version` - (Optional, String) Kernel version, you can enter it when modifying.
223225
* `db_mode` - (Optional, String) Specify DB mode, only available when `db_type` is `MYSQL`. Values: `NORMAL` (Default), `SERVERLESS`.
224226
* `force_delete` - (Optional, Bool) Indicate whether to delete cluster instance directly or not. Default is false. If set true, the cluster and its `All RELATED INSTANCES` will be deleted instead of staying recycle bin. Note: works for both `PREPAID` and `POSTPAID_BY_HOUR` cluster.
227+
* `instance_count` - (Optional, Int, ForceNew) The number of instances, the range is (0,16], the default value is 2 (i.e. one RW instance + one Ro instance), the passed n means 1 RW instance + n-1 Ro instances (with the same specifications), if you need a more accurate cluster composition, please use InstanceInitInfos.
225228
* `instance_cpu_core` - (Optional, Int) The number of CPU cores of read-write type instance in the CynosDB cluster. Required while creating normal cluster. Note: modification of this field will take effect immediately, if want to upgrade on maintenance window, please upgrade from console.
226229
* `instance_init_infos` - (Optional, List, ForceNew) Instance initialization configuration information, mainly used to select instances of different specifications when purchasing a cluster.
227230
* `instance_maintain_duration` - (Optional, Int) Duration time for maintenance, unit in second. `3600` by default.

0 commit comments

Comments
 (0)