@@ -104,7 +104,12 @@ func resourceTencentCloudSslCertificate() *schema.Resource {
104104 return
105105 },
106106 },
107-
107+ "tags" : {
108+ Type : schema .TypeMap ,
109+ Optional : true ,
110+ Computed : true ,
111+ Description : "Tags of the SSL certificate." ,
112+ },
108113 // computed
109114 "product_zh_name" : {
110115 Type : schema .TypeString ,
@@ -208,6 +213,15 @@ func resourceTencentCloudSslCertificateCreate(d *schema.ResourceData, m interfac
208213 log .Printf ("[CRITAL]%s create certificate failed, reason: %v" , logId , outErr )
209214 return outErr
210215 }
216+
217+ if tags := helper .GetTags (d , "tags" ); len (tags ) > 0 {
218+ tagClient := m .(* TencentCloudClient ).apiV3Conn
219+ tagService := & TagService {client : tagClient }
220+ resourceName := BuildTagResourceName ("ssl" , "certificate" , tagClient .Region , id )
221+ if err := tagService .ModifyTags (ctx , resourceName , tags , nil ); err != nil {
222+ return err
223+ }
224+ }
211225 d .SetId (id )
212226
213227 return resourceTencentCloudSslCertificateRead (d , m )
@@ -287,6 +301,14 @@ func resourceTencentCloudSslCertificateRead(d *schema.ResourceData, m interface{
287301 }
288302 _ = d .Set ("subject_names" , subjectAltNames )
289303
304+ tagClient := m .(* TencentCloudClient ).apiV3Conn
305+ tagService := TagService {client : tagClient }
306+
307+ tags , err := tagService .DescribeResourceTags (ctx , "ssl" , "certificate" , tagClient .Region , d .Id ())
308+ if err != nil {
309+ return err
310+ }
311+ _ = d .Set ("tags" , tags )
290312 return nil
291313}
292314
@@ -347,6 +369,18 @@ func resourceTencentCloudSslCertificateUpdate(d *schema.ResourceData, m interfac
347369 }
348370 d .SetPartial ("project_id" )
349371 }
372+
373+ if d .HasChange ("tags" ) {
374+ oldInterface , newInterface := d .GetChange ("tags" )
375+ replaceTags , deleteTags := diffTags (oldInterface .(map [string ]interface {}), newInterface .(map [string ]interface {}))
376+ tagClient := m .(* TencentCloudClient ).apiV3Conn
377+ tagService := TagService {client : tagClient }
378+ resourceName := BuildTagResourceName ("ssl" , "certificate" , tagClient .Region , id )
379+ err := tagService .ModifyTags (ctx , resourceName , replaceTags , deleteTags )
380+ if err != nil {
381+ return err
382+ }
383+ }
350384 d .Partial (false )
351385 return resourceTencentCloudSslCertificateRead (d , m )
352386}
0 commit comments