@@ -59,7 +59,6 @@ func resourceTencentCloudTcrInstance() *schema.Resource {
5959 "tags" : {
6060 Type : schema .TypeMap ,
6161 Optional : true ,
62- ForceNew : true ,
6362 Description : "The available tags within this TCR instance." ,
6463 },
6564 "open_public_operation" : {
@@ -110,15 +109,14 @@ func resourceTencentCloudTcrInstanceCreate(d *schema.ResourceData, meta interfac
110109 var (
111110 name = d .Get ("name" ).(string )
112111 insType = d .Get ("instance_type" ).(string )
113- tags = helper .GetTags (d , "tags" )
114112 outErr , inErr error
115113 instanceId string
116114 instanceStatus string
117115 operation bool
118116 )
119117
120118 outErr = resource .Retry (writeRetryTimeout , func () * resource.RetryError {
121- instanceId , inErr = tcrService .CreateTCRInstance (ctx , name , insType , tags )
119+ instanceId , inErr = tcrService .CreateTCRInstance (ctx , name , insType , map [ string ] string {} )
122120 if inErr != nil {
123121 return retryError (inErr )
124122 }
@@ -168,6 +166,15 @@ func resourceTencentCloudTcrInstanceCreate(d *schema.ResourceData, meta interfac
168166 }
169167 }
170168
169+ if tags := helper .GetTags (d , "tags" ); len (tags ) > 0 {
170+ tagService := TagService {client : meta .(* TencentCloudClient ).apiV3Conn }
171+ region := meta .(* TencentCloudClient ).apiV3Conn .Region
172+ resourceName := BuildTagResourceName ("tcr" , "instance" , region , d .Id ())
173+ if err := tagService .ModifyTags (ctx , resourceName , tags , nil ); err != nil {
174+ return err
175+ }
176+ }
177+
171178 return resourceTencentCloudTcrInstanceRead (d , meta )
172179}
173180
@@ -269,6 +276,19 @@ func resourceTencentCloudTcrInstanceUpdate(d *schema.ResourceData, meta interfac
269276 return outErr
270277 }
271278 }
279+
280+ if d .HasChange ("tags" ) {
281+ oldTags , newTags := d .GetChange ("tags" )
282+ replaceTags , deleteTags := diffTags (oldTags .(map [string ]interface {}), newTags .(map [string ]interface {}))
283+ region := meta .(* TencentCloudClient ).apiV3Conn .Region
284+ resourceName := BuildTagResourceName ("tcr" , "instance" , region , d .Id ())
285+ tagService := TagService {client : meta .(* TencentCloudClient ).apiV3Conn }
286+ if err := tagService .ModifyTags (ctx , resourceName , replaceTags , deleteTags ); err != nil {
287+ return err
288+ }
289+
290+ d .SetPartial ("tags" )
291+ }
272292 return resourceTencentCloudTcrInstanceRead (d , meta )
273293}
274294
0 commit comments