Skip to content

fix(mqtt): [124225377] tencentcloud_mqtt_instance support automatic_activation field edit #3374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3374.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_mqtt_instance: support `automatic_activation` field edit
```
33 changes: 31 additions & 2 deletions tencentcloud/services/mqtt/resource_tc_mqtt_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func ResourceTencentCloudMqttInstance() *schema.Resource {
"instance_type": {
Type: schema.TypeString,
Required: true,
Description: "Instance type,\nBASIC for Basic Edition\nPRO for Professional Edition.",
Description: "Instance type. PRO for Professional Edition; PLATINUM for Platinum Edition.",
},

"name": {
Expand Down Expand Up @@ -100,8 +100,9 @@ func ResourceTencentCloudMqttInstance() *schema.Resource {

"automatic_activation": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Is the automatic registration certificate automatically activated.",
Description: "Is the automatic registration certificate automatically activated. Default is false.",
},

"force_delete": {
Expand Down Expand Up @@ -225,6 +226,30 @@ func ResourceTencentCloudMqttInstanceCreate(d *schema.ResourceData, meta interfa
return reqErr
}

// open automatic_activation
if v, ok := d.GetOkExists("automatic_activation"); ok {
if v.(bool) {
modifyRequest := mqttv20240516.NewModifyInstanceRequest()
modifyRequest.InstanceId = &instanceId
modifyRequest.AutomaticActivation = helper.Bool(v.(bool))
reqErr := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseMqttV20240516Client().ModifyInstanceWithContext(ctx, modifyRequest)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, modifyRequest.GetAction(), modifyRequest.ToJsonString(), result.ToJsonString())
}

return nil
})

if reqErr != nil {
log.Printf("[CRITAL]%s update mqtt failed, reason:%+v", logId, reqErr)
return reqErr
}
}
}

if tags := helper.GetTags(d, "tags"); len(tags) > 0 {
tagService := svctag.NewTagService(meta.(tccommon.ProviderMeta).GetAPIV3Conn())
region := meta.(tccommon.ProviderMeta).GetAPIV3Conn().Region
Expand Down Expand Up @@ -354,6 +379,10 @@ func ResourceTencentCloudMqttInstanceUpdate(d *schema.ResourceData, meta interfa
request.SkuCode = helper.String(v.(string))
}

if v, ok := d.GetOkExists("automatic_activation"); ok {
request.AutomaticActivation = helper.Bool(v.(bool))
}

reqErr := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseMqttV20240516Client().ModifyInstanceWithContext(ctx, request)
if e != nil {
Expand Down
15 changes: 8 additions & 7 deletions tencentcloud/services/mqtt/resource_tc_mqtt_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ resource "tencentcloud_subnet" "subnet" {

// create mqtt instance
resource "tencentcloud_mqtt_instance" "example" {
instance_type = "BASIC"
instance_type = "PRO"
name = "tf-example"
sku_code = "basic_2k"
sku_code = "pro_6k_1"
remark = "remarks."
vpc_list {
vpc_id = tencentcloud_vpc.vpc.id
Expand Down Expand Up @@ -67,16 +67,17 @@ resource "tencentcloud_subnet" "subnet" {
resource "tencentcloud_mqtt_instance" "example" {
instance_type = "PRO"
name = "tf-example"
sku_code = "pro_6k_1"
sku_code = "pro_10k_2"
remark = "remarks."
vpc_list {
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
}
pay_mode = 1
time_span = 1
renew_flag = 1
force_delete = false
pay_mode = 1
time_span = 1
renew_flag = 1
force_delete = false
automatic_activation = true
tags = {
createBy = "Terraform"
}
Expand Down
21 changes: 10 additions & 11 deletions website/docs/r/mqtt_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ resource "tencentcloud_subnet" "subnet" {

// create mqtt instance
resource "tencentcloud_mqtt_instance" "example" {
instance_type = "BASIC"
instance_type = "PRO"
name = "tf-example"
sku_code = "basic_2k"
sku_code = "pro_6k_1"
remark = "remarks."
vpc_list {
vpc_id = tencentcloud_vpc.vpc.id
Expand Down Expand Up @@ -78,16 +78,17 @@ resource "tencentcloud_subnet" "subnet" {
resource "tencentcloud_mqtt_instance" "example" {
instance_type = "PRO"
name = "tf-example"
sku_code = "pro_6k_1"
sku_code = "pro_10k_2"
remark = "remarks."
vpc_list {
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
}
pay_mode = 1
time_span = 1
renew_flag = 1
force_delete = false
pay_mode = 1
time_span = 1
renew_flag = 1
force_delete = false
automatic_activation = true
tags = {
createBy = "Terraform"
}
Expand All @@ -98,11 +99,10 @@ resource "tencentcloud_mqtt_instance" "example" {

The following arguments are supported:

* `instance_type` - (Required, String) Instance type,
BASIC for Basic Edition
PRO for Professional Edition.
* `instance_type` - (Required, String) Instance type. PRO for Professional Edition; PLATINUM for Platinum Edition.
* `name` - (Required, String) Instance name.
* `sku_code` - (Required, String) Product SKU, available SKUs can be queried via the DescribeProductSKUList API.
* `automatic_activation` - (Optional, Bool) Is the automatic registration certificate automatically activated. Default is false.
* `force_delete` - (Optional, Bool) 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.
* `pay_mode` - (Optional, Int) Payment mode (0: Postpaid; 1: Prepaid).
* `remark` - (Optional, String) Remarks.
Expand All @@ -121,7 +121,6 @@ The `vpc_list` object supports the following:
In addition to all arguments above, the following attributes are exported:

* `id` - ID of the resource.
* `automatic_activation` - Is the automatic registration certificate automatically activated.
* `device_certificate_provision_type` - Client certificate registration method: JITP: Automatic registration; API: Manually register through the API.


Loading