@@ -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