diff --git a/.changelog/3374.txt b/.changelog/3374.txt new file mode 100644 index 0000000000..74b2900673 --- /dev/null +++ b/.changelog/3374.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_mqtt_instance: support `automatic_activation` field edit +``` \ No newline at end of file diff --git a/tencentcloud/services/mqtt/resource_tc_mqtt_instance.go b/tencentcloud/services/mqtt/resource_tc_mqtt_instance.go index 2ed1220c3b..ce872e528e 100644 --- a/tencentcloud/services/mqtt/resource_tc_mqtt_instance.go +++ b/tencentcloud/services/mqtt/resource_tc_mqtt_instance.go @@ -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": { @@ -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": { @@ -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 @@ -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 { diff --git a/tencentcloud/services/mqtt/resource_tc_mqtt_instance.md b/tencentcloud/services/mqtt/resource_tc_mqtt_instance.md index 55b430942d..ea9010caa5 100644 --- a/tencentcloud/services/mqtt/resource_tc_mqtt_instance.md +++ b/tencentcloud/services/mqtt/resource_tc_mqtt_instance.md @@ -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 @@ -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" } diff --git a/website/docs/r/mqtt_instance.html.markdown b/website/docs/r/mqtt_instance.html.markdown index 5a3fe925bb..1123ea5571 100644 --- a/website/docs/r/mqtt_instance.html.markdown +++ b/website/docs/r/mqtt_instance.html.markdown @@ -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 @@ -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" } @@ -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. @@ -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.