Skip to content

Commit a65ca7b

Browse files
authored
fix cls logix (#1115)
1 parent 0dcdb37 commit a65ca7b

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

tencentcloud/resource_tc_cls_logset.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ func resourceTencentCloudClsLogsetUpdate(d *schema.ResourceData, meta interface{
166166

167167
request.LogsetId = helper.String(d.Id())
168168

169-
if d.HasChange("logset_name") {
169+
if d.HasChange("logset_name") || d.HasChange("tags") {
170170
request.LogsetName = helper.String(d.Get("logset_name").(string))
171-
}
172171

173-
if d.HasChange("tags") {
174172
tags := d.Get("tags").(map[string]interface{})
175173
request.Tags = make([]*cls.Tag, 0, len(tags))
176174
for k, v := range tags {
175+
key := k
176+
value := v
177177
request.Tags = append(request.Tags, &cls.Tag{
178-
Key: &k,
179-
Value: helper.String(v.(string)),
178+
Key: &key,
179+
Value: helper.String(value.(string)),
180180
})
181181
}
182182
}

tencentcloud/resource_tc_cls_topic.go

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func resourceTencentCloudClsTopic() *schema.Resource {
6262
"partition_count": {
6363
Type: schema.TypeInt,
6464
Optional: true,
65-
ForceNew: true,
65+
Computed: true,
6666
Description: "Number of log topic partitions. Default value: 1. Maximum value: 10.",
6767
},
6868
"tags": {
@@ -73,25 +73,27 @@ func resourceTencentCloudClsTopic() *schema.Resource {
7373
"auto_split": {
7474
Type: schema.TypeBool,
7575
Optional: true,
76-
Default: true,
76+
Computed: true,
7777
Description: "Whether to enable automatic split. Default value: true.",
7878
},
7979
"max_split_partitions": {
8080
Type: schema.TypeInt,
8181
Optional: true,
82+
Computed: true,
8283
Description: "Maximum number of partitions to split into for this topic if" +
8384
" automatic split is enabled. Default value: 50.",
8485
},
8586
"storage_type": {
8687
Type: schema.TypeString,
8788
Optional: true,
88-
ForceNew: true,
89+
Computed: true,
8990
Description: "Log topic storage class. Valid values: hot: real-time storage; cold: offline storage. Default value: hot. If cold is passed in, " +
9091
"please contact the customer service to add the log topic to the allowlist first..",
9192
},
9293
"period": {
9394
Type: schema.TypeInt,
9495
Optional: true,
96+
Computed: true,
9597
Description: "Lifecycle in days. Value range: 1~366. Default value: 30.",
9698
},
9799
},
@@ -122,14 +124,18 @@ func resourceTencentCloudClsTopicCreate(d *schema.ResourceData, meta interface{}
122124

123125
if tags := helper.GetTags(d, "tags"); len(tags) > 0 {
124126
for k, v := range tags {
127+
key := k
128+
value := v
125129
request.Tags = append(request.Tags, &cls.Tag{
126-
Key: &k,
127-
Value: &v,
130+
Key: &key,
131+
Value: &value,
128132
})
129133
}
130134
}
131135

132-
request.AutoSplit = helper.Bool(d.Get("auto_split").(bool))
136+
if v, ok := d.GetOk("max_split_partitions"); ok {
137+
request.AutoSplit = helper.Bool(v.(bool))
138+
}
133139

134140
if v, ok := d.GetOk("max_split_partitions"); ok {
135141
request.MaxSplitPartitions = helper.IntInt64(v.(int))
@@ -210,17 +216,28 @@ func resourceTencentCloudClsTopicUpdate(d *schema.ResourceData, meta interface{}
210216

211217
request.TopicId = helper.String(d.Id())
212218

219+
if d.HasChange("partition_count") {
220+
return fmt.Errorf("`partition_count` do not support change now.")
221+
}
222+
223+
if d.HasChange("storage_type") {
224+
return fmt.Errorf("`storage_type` do not support change now.")
225+
}
226+
213227
if d.HasChange("topic_name") {
214228
request.TopicName = helper.String(d.Get("topic_name").(string))
215229
}
216230

217231
if d.HasChange("tags") {
232+
218233
tags := d.Get("tags").(map[string]interface{})
219234
request.Tags = make([]*cls.Tag, 0, len(tags))
220235
for k, v := range tags {
236+
key := k
237+
value := v
221238
request.Tags = append(request.Tags, &cls.Tag{
222-
Key: &k,
223-
Value: helper.String(v.(string)),
239+
Key: &key,
240+
Value: helper.String(value.(string)),
224241
})
225242
}
226243
}

0 commit comments

Comments
 (0)