Skip to content

Commit d627509

Browse files
committed
fix: modify service tag
1 parent 817358f commit d627509

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

.changelog/2096.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ tencentcloud_tse_cngw_route_rate_limit
2727
```
2828

2929
```release-note:enhancement
30-
resource/tencentcloud_tse_cngw_service: Remove tags that don't work
30+
resource/tencentcloud_tse_cngw_service: Deprecate ineffective tags
3131
```

tencentcloud/resource_tc_tse_cngw_service.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ func resourceTencentCloudTseCngwService() *schema.Resource {
286286
Type: schema.TypeString,
287287
Description: "service id.",
288288
},
289+
290+
"tags": {
291+
Type: schema.TypeMap,
292+
Optional: true,
293+
Description: "Tag description list.",
294+
Deprecated: "Deprecate ineffective tags",
295+
},
289296
},
290297
}
291298
}
@@ -425,6 +432,16 @@ func resourceTencentCloudTseCngwServiceCreate(d *schema.ResourceData, meta inter
425432

426433
d.SetId(gatewayId + FILED_SP + name)
427434

435+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
436+
if tags := helper.GetTags(d, "tags"); len(tags) > 0 {
437+
tagService := TagService{client: meta.(*TencentCloudClient).apiV3Conn}
438+
region := meta.(*TencentCloudClient).apiV3Conn.Region
439+
resourceName := fmt.Sprintf("qcs::tse:%s:uin/:cngw_service/%s", region, d.Id())
440+
if err := tagService.ModifyTags(ctx, resourceName, tags, nil); err != nil {
441+
return err
442+
}
443+
}
444+
428445
return resourceTencentCloudTseCngwServiceRead(d, meta)
429446
}
430447

@@ -597,6 +614,14 @@ func resourceTencentCloudTseCngwServiceRead(d *schema.ResourceData, meta interfa
597614
_ = d.Set("service_id", cngwService.ID)
598615
}
599616

617+
tcClient := meta.(*TencentCloudClient).apiV3Conn
618+
tagService := &TagService{client: tcClient}
619+
tags, err := tagService.DescribeResourceTags(ctx, "tse", "cngw_service", tcClient.Region, d.Id())
620+
if err != nil {
621+
return err
622+
}
623+
_ = d.Set("tags", tags)
624+
600625
return nil
601626
}
602627

@@ -754,6 +779,17 @@ func resourceTencentCloudTseCngwServiceUpdate(d *schema.ResourceData, meta inter
754779
return err
755780
}
756781

782+
if d.HasChange("tags") {
783+
tcClient := meta.(*TencentCloudClient).apiV3Conn
784+
tagService := &TagService{client: tcClient}
785+
oldTags, newTags := d.GetChange("tags")
786+
replaceTags, deleteTags := diffTags(oldTags.(map[string]interface{}), newTags.(map[string]interface{}))
787+
resourceName := BuildTagResourceName("tse", "cngw_service", tcClient.Region, d.Id())
788+
if err := tagService.ModifyTags(ctx, resourceName, replaceTags, deleteTags); err != nil {
789+
return err
790+
}
791+
}
792+
757793
return resourceTencentCloudTseCngwServiceRead(d, meta)
758794
}
759795

website/docs/r/tse_cngw_service.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ The following arguments are supported:
8888
* `timeout` - (Required, Int) time out, unit:ms.
8989
* `upstream_info` - (Required, List) service config information.
9090
* `upstream_type` - (Required, String) service type. Reference value:`Kubernetes`, `Registry`, `IPList`, `HostIP`, `Scf`.
91+
* `tags` - (Optional, Map, **Deprecated**) Deprecate ineffective tags Tag description list.
9192

9293
The `targets` object supports the following:
9394

0 commit comments

Comments
 (0)