Skip to content

Commit 4cefe6e

Browse files
authored
fix(mqtt): [124225377] tencentcloud_mqtt_instance support automatic_activation field edit (#3374)
* add * add
1 parent e086338 commit 4cefe6e

File tree

4 files changed

+52
-20
lines changed

4 files changed

+52
-20
lines changed

.changelog/3374.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_mqtt_instance: support `automatic_activation` field edit
3+
```

tencentcloud/services/mqtt/resource_tc_mqtt_instance.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func ResourceTencentCloudMqttInstance() *schema.Resource {
2525
"instance_type": {
2626
Type: schema.TypeString,
2727
Required: true,
28-
Description: "Instance type,\nBASIC for Basic Edition\nPRO for Professional Edition.",
28+
Description: "Instance type. PRO for Professional Edition; PLATINUM for Platinum Edition.",
2929
},
3030

3131
"name": {
@@ -100,8 +100,9 @@ func ResourceTencentCloudMqttInstance() *schema.Resource {
100100

101101
"automatic_activation": {
102102
Type: schema.TypeBool,
103+
Optional: true,
103104
Computed: true,
104-
Description: "Is the automatic registration certificate automatically activated.",
105+
Description: "Is the automatic registration certificate automatically activated. Default is false.",
105106
},
106107

107108
"force_delete": {
@@ -225,6 +226,30 @@ func ResourceTencentCloudMqttInstanceCreate(d *schema.ResourceData, meta interfa
225226
return reqErr
226227
}
227228

229+
// open automatic_activation
230+
if v, ok := d.GetOkExists("automatic_activation"); ok {
231+
if v.(bool) {
232+
modifyRequest := mqttv20240516.NewModifyInstanceRequest()
233+
modifyRequest.InstanceId = &instanceId
234+
modifyRequest.AutomaticActivation = helper.Bool(v.(bool))
235+
reqErr := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
236+
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseMqttV20240516Client().ModifyInstanceWithContext(ctx, modifyRequest)
237+
if e != nil {
238+
return tccommon.RetryError(e)
239+
} else {
240+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, modifyRequest.GetAction(), modifyRequest.ToJsonString(), result.ToJsonString())
241+
}
242+
243+
return nil
244+
})
245+
246+
if reqErr != nil {
247+
log.Printf("[CRITAL]%s update mqtt failed, reason:%+v", logId, reqErr)
248+
return reqErr
249+
}
250+
}
251+
}
252+
228253
if tags := helper.GetTags(d, "tags"); len(tags) > 0 {
229254
tagService := svctag.NewTagService(meta.(tccommon.ProviderMeta).GetAPIV3Conn())
230255
region := meta.(tccommon.ProviderMeta).GetAPIV3Conn().Region
@@ -354,6 +379,10 @@ func ResourceTencentCloudMqttInstanceUpdate(d *schema.ResourceData, meta interfa
354379
request.SkuCode = helper.String(v.(string))
355380
}
356381

382+
if v, ok := d.GetOkExists("automatic_activation"); ok {
383+
request.AutomaticActivation = helper.Bool(v.(bool))
384+
}
385+
357386
reqErr := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
358387
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseMqttV20240516Client().ModifyInstanceWithContext(ctx, request)
359388
if e != nil {

tencentcloud/services/mqtt/resource_tc_mqtt_instance.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ resource "tencentcloud_subnet" "subnet" {
2626
2727
// create mqtt instance
2828
resource "tencentcloud_mqtt_instance" "example" {
29-
instance_type = "BASIC"
29+
instance_type = "PRO"
3030
name = "tf-example"
31-
sku_code = "basic_2k"
31+
sku_code = "pro_6k_1"
3232
remark = "remarks."
3333
vpc_list {
3434
vpc_id = tencentcloud_vpc.vpc.id
@@ -67,16 +67,17 @@ resource "tencentcloud_subnet" "subnet" {
6767
resource "tencentcloud_mqtt_instance" "example" {
6868
instance_type = "PRO"
6969
name = "tf-example"
70-
sku_code = "pro_6k_1"
70+
sku_code = "pro_10k_2"
7171
remark = "remarks."
7272
vpc_list {
7373
vpc_id = tencentcloud_vpc.vpc.id
7474
subnet_id = tencentcloud_subnet.subnet.id
7575
}
76-
pay_mode = 1
77-
time_span = 1
78-
renew_flag = 1
79-
force_delete = false
76+
pay_mode = 1
77+
time_span = 1
78+
renew_flag = 1
79+
force_delete = false
80+
automatic_activation = true
8081
tags = {
8182
createBy = "Terraform"
8283
}

website/docs/r/mqtt_instance.html.markdown

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ resource "tencentcloud_subnet" "subnet" {
3737
3838
// create mqtt instance
3939
resource "tencentcloud_mqtt_instance" "example" {
40-
instance_type = "BASIC"
40+
instance_type = "PRO"
4141
name = "tf-example"
42-
sku_code = "basic_2k"
42+
sku_code = "pro_6k_1"
4343
remark = "remarks."
4444
vpc_list {
4545
vpc_id = tencentcloud_vpc.vpc.id
@@ -78,16 +78,17 @@ resource "tencentcloud_subnet" "subnet" {
7878
resource "tencentcloud_mqtt_instance" "example" {
7979
instance_type = "PRO"
8080
name = "tf-example"
81-
sku_code = "pro_6k_1"
81+
sku_code = "pro_10k_2"
8282
remark = "remarks."
8383
vpc_list {
8484
vpc_id = tencentcloud_vpc.vpc.id
8585
subnet_id = tencentcloud_subnet.subnet.id
8686
}
87-
pay_mode = 1
88-
time_span = 1
89-
renew_flag = 1
90-
force_delete = false
87+
pay_mode = 1
88+
time_span = 1
89+
renew_flag = 1
90+
force_delete = false
91+
automatic_activation = true
9192
tags = {
9293
createBy = "Terraform"
9394
}
@@ -98,11 +99,10 @@ resource "tencentcloud_mqtt_instance" "example" {
9899

99100
The following arguments are supported:
100101

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

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

127126

0 commit comments

Comments
 (0)