@@ -62,7 +62,7 @@ func resourceTencentCloudClsTopic() *schema.Resource {
62
62
"partition_count" : {
63
63
Type : schema .TypeInt ,
64
64
Optional : true ,
65
- ForceNew : true ,
65
+ Computed : true ,
66
66
Description : "Number of log topic partitions. Default value: 1. Maximum value: 10." ,
67
67
},
68
68
"tags" : {
@@ -73,25 +73,27 @@ func resourceTencentCloudClsTopic() *schema.Resource {
73
73
"auto_split" : {
74
74
Type : schema .TypeBool ,
75
75
Optional : true ,
76
- Default : true ,
76
+ Computed : true ,
77
77
Description : "Whether to enable automatic split. Default value: true." ,
78
78
},
79
79
"max_split_partitions" : {
80
80
Type : schema .TypeInt ,
81
81
Optional : true ,
82
+ Computed : true ,
82
83
Description : "Maximum number of partitions to split into for this topic if" +
83
84
" automatic split is enabled. Default value: 50." ,
84
85
},
85
86
"storage_type" : {
86
87
Type : schema .TypeString ,
87
88
Optional : true ,
88
- ForceNew : true ,
89
+ Computed : true ,
89
90
Description : "Log topic storage class. Valid values: hot: real-time storage; cold: offline storage. Default value: hot. If cold is passed in, " +
90
91
"please contact the customer service to add the log topic to the allowlist first.." ,
91
92
},
92
93
"period" : {
93
94
Type : schema .TypeInt ,
94
95
Optional : true ,
96
+ Computed : true ,
95
97
Description : "Lifecycle in days. Value range: 1~366. Default value: 30." ,
96
98
},
97
99
},
@@ -122,14 +124,18 @@ func resourceTencentCloudClsTopicCreate(d *schema.ResourceData, meta interface{}
122
124
123
125
if tags := helper .GetTags (d , "tags" ); len (tags ) > 0 {
124
126
for k , v := range tags {
127
+ key := k
128
+ value := v
125
129
request .Tags = append (request .Tags , & cls.Tag {
126
- Key : & k ,
127
- Value : & v ,
130
+ Key : & key ,
131
+ Value : & value ,
128
132
})
129
133
}
130
134
}
131
135
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
+ }
133
139
134
140
if v , ok := d .GetOk ("max_split_partitions" ); ok {
135
141
request .MaxSplitPartitions = helper .IntInt64 (v .(int ))
@@ -210,17 +216,28 @@ func resourceTencentCloudClsTopicUpdate(d *schema.ResourceData, meta interface{}
210
216
211
217
request .TopicId = helper .String (d .Id ())
212
218
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
+
213
227
if d .HasChange ("topic_name" ) {
214
228
request .TopicName = helper .String (d .Get ("topic_name" ).(string ))
215
229
}
216
230
217
231
if d .HasChange ("tags" ) {
232
+
218
233
tags := d .Get ("tags" ).(map [string ]interface {})
219
234
request .Tags = make ([]* cls.Tag , 0 , len (tags ))
220
235
for k , v := range tags {
236
+ key := k
237
+ value := v
221
238
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 )),
224
241
})
225
242
}
226
243
}
0 commit comments