Skip to content

Commit f73741d

Browse files
authored
fix(cynosdb): [116884831]modify tag (#2674)
* fix: modify tag * feat: add changelog
1 parent cea00cb commit f73741d

File tree

3 files changed

+43
-38
lines changed

3 files changed

+43
-38
lines changed

.changelog/2674.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: modify tag.
3+
```

tencentcloud/services/cynosdb/resource_tc_cynosdb_cluster.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func resourceTencentCloudCynosdbClusterCreate(d *schema.ResourceData, meta inter
212212

213213
// set tags
214214
if tags := helper.GetTags(d, "tags"); len(tags) > 0 {
215-
resourceName := tccommon.BuildTagResourceName("cynosdb", "cluster", region, id)
215+
resourceName := tccommon.BuildTagResourceName("cynosdb", "instance", region, id)
216216
if err := tagService.ModifyTags(ctx, resourceName, tags, nil); err != nil {
217217
return err
218218
}
@@ -352,7 +352,7 @@ func resourceTencentCloudCynosdbClusterRead(d *schema.ResourceData, meta interfa
352352

353353
//tag
354354
tagService := svctag.NewTagService(client)
355-
tags, err := tagService.DescribeResourceTags(ctx, "cynosdb", "cluster", client.Region, id)
355+
tags, err := tagService.DescribeResourceTags(ctx, "cynosdb", "instance", client.Region, id)
356356
if err != nil {
357357
return err
358358
}
@@ -652,7 +652,7 @@ func resourceTencentCloudCynosdbClusterUpdate(d *schema.ResourceData, meta inter
652652
oldTags, newTags := d.GetChange("tags")
653653
replaceTags, deleteTags := svctag.DiffTags(oldTags.(map[string]interface{}), newTags.(map[string]interface{}))
654654

655-
resourceName := tccommon.BuildTagResourceName("cynosdb", "cluster", region, clusterId)
655+
resourceName := tccommon.BuildTagResourceName("cynosdb", "instance", region, clusterId)
656656
if err := tagService.ModifyTags(ctx, resourceName, replaceTags, deleteTags); err != nil {
657657
return err
658658
}

tencentcloud/services/cynosdb/resource_tc_cynosdb_cluster_test.go

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func TestAccTencentCloudCynosdbClusterResourceBasic(t *testing.T) {
6868
Check: resource.ComposeTestCheckFunc(
6969
testAccCheckCynosdbClusterExists("tencentcloud_cynosdb_cluster.foo"),
7070
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "available_zone", "ap-guangzhou-4"),
71-
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "vpc_id", "vpc-4owdpnwr"),
72-
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "subnet_id", "subnet-qpxez62e"),
71+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "vpc_id", "vpc-m0d2dbnn"),
72+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "subnet_id", "subnet-j10lsueq"),
7373
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "db_type", "MYSQL"),
7474
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "db_version", "5.7"),
7575
// resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "storage_limit", "1000"),
@@ -79,7 +79,7 @@ func TestAccTencentCloudCynosdbClusterResourceBasic(t *testing.T) {
7979
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_maintain_weekdays.#", "7"),
8080
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_cpu_core", "1"),
8181
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_memory_size", "2"),
82-
//resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "tags.test", "test"),
82+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "tags.test", "test"),
8383
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "force_delete", "true"),
8484
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "rw_group_sg.#", "1"),
8585
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "ro_group_sg.#", "1"),
@@ -116,22 +116,22 @@ func TestAccTencentCloudCynosdbClusterResourceBasic(t *testing.T) {
116116
{
117117
Config: testAccCynosdbCluster_update,
118118
Check: resource.ComposeTestCheckFunc(
119-
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "vpc_id", "vpc-k1t8ickr"),
120-
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "subnet_id", "subnet-jdi5xn22"),
121-
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_maintain_duration", "7200"),
122-
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_maintain_start_time", "21600"),
123-
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_maintain_weekdays.#", "6"),
119+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "vpc_id", "vpc-m0d2dbnn"),
120+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "subnet_id", "subnet-j10lsueq"),
121+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_maintain_duration", "3600"),
122+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_maintain_start_time", "10800"),
123+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_maintain_weekdays.#", "7"),
124124
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_cpu_core", "2"),
125125
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "instance_memory_size", "4"),
126126
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "rw_group_sg.#", "1"),
127127
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "ro_group_sg.#", "1"),
128128
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "param_items.#", "2"),
129129
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "param_items.0.name", "character_set_server"),
130130
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "param_items.0.old_value", "utf8"),
131-
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "param_items.0.current_value", "utf8mb4"),
131+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "param_items.0.current_value", "utf8"),
132132
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "param_items.1.name", "time_zone"),
133133
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "param_items.1.old_value", "+09:00"),
134-
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "param_items.1.current_value", "+08:00"),
134+
resource.TestCheckResourceAttr("tencentcloud_cynosdb_cluster.foo", "param_items.1.current_value", "+09:00"),
135135
),
136136
},
137137
},
@@ -238,22 +238,26 @@ func testAccCheckCynosdbClusterExists(n string) resource.TestCheckFunc {
238238
}
239239
}
240240

241-
const testAccCynosdbBasic = tcacctest.DefaultSecurityGroupData + `
241+
const testAccCynosdbBasic = `
242242
variable "availability_zone" {
243243
default = "ap-guangzhou-4"
244244
}
245245
246246
variable "my_vpc" {
247-
default = "vpc-4owdpnwr"
247+
default = "vpc-m0d2dbnn"
248248
}
249249
250250
variable "my_subnet" {
251-
default = "subnet-qpxez62e"
251+
default = "subnet-j10lsueq"
252252
}
253253
254254
variable "my_param_template" {
255255
default = "15765"
256256
}
257+
258+
variable "rw_group_sg" {
259+
default = "sg-05f7wnhn"
260+
}
257261
`
258262

259263
const testAccCynosdbCluster = testAccCynosdbBasic + `
@@ -289,70 +293,68 @@ resource "tencentcloud_cynosdb_cluster" "foo" {
289293
current_value = "+09:00"
290294
}
291295
292-
# tags = {
293-
# test = "test"
294-
# }
296+
tags = {
297+
test = "test"
298+
}
295299
296300
force_delete = true
297301
298302
rw_group_sg = [
299-
local.sg_id
303+
var.rw_group_sg
300304
]
301305
ro_group_sg = [
302-
local.sg_id
306+
var.rw_group_sg
303307
]
304-
prarm_template_id = var.my_param_template
308+
# prarm_template_id = var.my_param_template
305309
}
306310
`
307311

308312
const testAccCynosdbCluster_update = testAccCynosdbBasic + `
309313
resource "tencentcloud_cynosdb_cluster" "foo" {
310314
available_zone = var.availability_zone
311-
vpc_id = "vpc-k1t8ickr"
312-
subnet_id = "subnet-jdi5xn22"
313-
old_ip_reserve_hours = 1
315+
vpc_id = var.my_vpc
316+
subnet_id = var.my_subnet
314317
db_type = "MYSQL"
315318
db_version = "5.7"
316319
storage_limit = 1000
317320
cluster_name = "tf-cynosdb-update"
318321
password = "cynos@123"
319-
instance_maintain_duration = 7200
320-
instance_maintain_start_time = 21600
322+
instance_maintain_duration = 3600
323+
instance_maintain_start_time = 10800
321324
instance_maintain_weekdays = [
322325
"Fri",
323326
"Mon",
324327
"Sat",
325328
"Sun",
326329
"Thu",
330+
"Wed",
327331
"Tue",
328332
]
329333
330334
instance_cpu_core = 2
331335
instance_memory_size = 4
332-
333336
param_items {
334337
name = "character_set_server"
335-
old_value = "utf8"
336-
current_value = "utf8mb4"
338+
old_value = "utf8"
339+
current_value = "utf8"
337340
}
338-
339341
param_items {
340342
name = "time_zone"
341-
old_value = "+09:00"
342-
current_value = "+08:00"
343+
old_value = "+09:00"
344+
current_value = "+09:00"
343345
}
344346
345-
# tags = {
346-
# test = "test-update"
347-
# }
347+
tags = {
348+
test = "test"
349+
}
348350
349351
force_delete = true
350352
351353
rw_group_sg = [
352-
local.sg_id2
354+
var.rw_group_sg
353355
]
354356
ro_group_sg = [
355-
local.sg_id2
357+
var.rw_group_sg
356358
]
357359
}
358360
`

0 commit comments

Comments
 (0)