@@ -119,6 +119,13 @@ func ResourceTencentCloudMqttInstance() *schema.Resource {
119119 Default : false ,
120120 Description : "Indicate whether to force delete the instance. Default is `false`. If set true, the instance will be permanently deleted instead of being moved into the recycle bin. Note: only works for `PREPAID` instance." ,
121121 },
122+
123+ "x509_mode" : {
124+ Type : schema .TypeString ,
125+ Optional : true ,
126+ Computed : true ,
127+ Description : "X509 certificate mode. Valid values: `TLS` (one-way authentication), `mTLS` (two-way authentication), `BYOC` (one device one certificate)." ,
128+ },
122129 },
123130 }
124131}
@@ -237,6 +244,7 @@ func ResourceTencentCloudMqttInstanceCreate(d *schema.ResourceData, meta interfa
237244 var (
238245 isAutomaticActivation bool
239246 isAuthorizationPolicy bool
247+ x509Mode string
240248 )
241249
242250 if v , ok := d .GetOkExists ("automatic_activation" ); ok {
@@ -247,12 +255,19 @@ func ResourceTencentCloudMqttInstanceCreate(d *schema.ResourceData, meta interfa
247255 isAuthorizationPolicy = v .(bool )
248256 }
249257
250- // open automatic_activation or authorization_policy
251- if isAutomaticActivation || isAuthorizationPolicy {
258+ if v , ok := d .GetOk ("x509_mode" ); ok {
259+ x509Mode = v .(string )
260+ }
261+
262+ // open automatic_activation or authorization_policy or set x509_mode
263+ if isAutomaticActivation || isAuthorizationPolicy || x509Mode != "" {
252264 modifyRequest := mqttv20240516 .NewModifyInstanceRequest ()
253265 modifyRequest .InstanceId = & instanceId
254266 modifyRequest .AutomaticActivation = helper .Bool (isAutomaticActivation )
255267 modifyRequest .AuthorizationPolicy = helper .Bool (isAuthorizationPolicy )
268+ if x509Mode != "" {
269+ modifyRequest .X509Mode = helper .String (x509Mode )
270+ }
256271 reqErr := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
257272 result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseMqttV20240516Client ().ModifyInstanceWithContext (ctx , modifyRequest )
258273 if e != nil {
@@ -346,6 +361,10 @@ func ResourceTencentCloudMqttInstanceRead(d *schema.ResourceData, meta interface
346361 _ = d .Set ("authorization_policy" , respData .AuthorizationPolicy )
347362 }
348363
364+ if respData .X509Mode != nil {
365+ _ = d .Set ("x509_mode" , respData .X509Mode )
366+ }
367+
349368 forceDelete := false
350369 if v , ok := d .GetOkExists ("force_delete" ); ok {
351370 forceDelete = v .(bool )
@@ -380,7 +399,7 @@ func ResourceTencentCloudMqttInstanceUpdate(d *schema.ResourceData, meta interfa
380399 }
381400
382401 needChange := false
383- mutableArgs := []string {"name" , "remark" , "sku_code" , "device_certificate_provision_type" , "automatic_activation" , "authorization_policy" }
402+ mutableArgs := []string {"name" , "remark" , "sku_code" , "device_certificate_provision_type" , "automatic_activation" , "authorization_policy" , "x509_mode" }
384403 for _ , v := range mutableArgs {
385404 if d .HasChange (v ) {
386405 needChange = true
@@ -411,6 +430,10 @@ func ResourceTencentCloudMqttInstanceUpdate(d *schema.ResourceData, meta interfa
411430 request .AuthorizationPolicy = helper .Bool (v .(bool ))
412431 }
413432
433+ if v , ok := d .GetOk ("x509_mode" ); ok {
434+ request .X509Mode = helper .String (v .(string ))
435+ }
436+
414437 reqErr := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
415438 result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseMqttV20240516Client ().ModifyInstanceWithContext (ctx , request )
416439 if e != nil {
0 commit comments