Skip to content

Commit a3c456d

Browse files
tongyimingmikatong
andauthored
offline permit_default_key_pair_login (#1899)
* offline permit_default_key_pair_login * add changelog --------- Co-authored-by: mikatong <mikatong@tencent.com>
1 parent f42be57 commit a3c456d

File tree

4 files changed

+5
-94
lines changed

4 files changed

+5
-94
lines changed

.changelog/1899.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_lighthouse_instance: offline param `permit_default_key_pair_login`
3+
```

tencentcloud/resource_tc_lighthouse_instance.go

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func resourceTencentCloudLighthouseInstance() *schema.Resource {
168168
Optional: true,
169169
Computed: true,
170170
ValidateFunc: validateAllowedStringValue([]string{"YES", "NO"}),
171-
Deprecated: "It will be deprecated. Use `tencentcloud_lighthouse_key_pair_attachment` manage key pair.",
171+
Deprecated: "It has been deprecated from version v1.81.8. Use `tencentcloud_lighthouse_key_pair_attachment` manage key pair.",
172172
Description: "Whether to allow login using the default key pair. `YES`: allow login; `NO`: disable login. Default: `YES`.",
173173
},
174174
"isolate_data_disk": {
@@ -415,23 +415,6 @@ func resourceTencentCloudLighthouseInstanceCreate(d *schema.ResourceData, meta i
415415
return err
416416
}
417417

418-
if v, ok := d.GetOk("permit_default_key_pair_login"); ok {
419-
permitLogin := v.(string)
420-
err = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
421-
e := lighthouseService.ModifyInstancesLoginKeyPairAttribute(ctx, instanceId, permitLogin)
422-
if e != nil {
423-
return retryError(e)
424-
} else {
425-
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
426-
}
427-
return nil
428-
})
429-
if err != nil {
430-
log.Printf("[CRITAL]%s update lighthouse instanceLoginKeyPair failed, reason:%+v", logId, err)
431-
return err
432-
}
433-
}
434-
435418
d.SetId(instanceId)
436419

437420
return resourceTencentCloudLighthouseInstanceRead(d, meta)
@@ -478,14 +461,6 @@ func resourceTencentCloudLighthouseInstanceRead(d *schema.ResourceData, meta int
478461
_ = d.Set("zone", instance.Zone)
479462
}
480463

481-
instanceLoginKeyPair, err := lighthouseService.DescribeLighthouseInstanceLoginKeyPairById(ctx, id)
482-
if err != nil {
483-
return err
484-
}
485-
486-
if instanceLoginKeyPair != nil && instanceLoginKeyPair.PermitLogin != nil {
487-
_ = d.Set("permit_default_key_pair_login", instanceLoginKeyPair.PermitLogin)
488-
}
489464
return nil
490465
}
491466

@@ -700,23 +675,6 @@ func resourceTencentCloudLighthouseInstanceUpdate(d *schema.ResourceData, meta i
700675
return fmt.Errorf("`containers` do not support change now.")
701676
}
702677

703-
if d.HasChange("permit_default_key_pair_login") {
704-
_, new := d.GetChange("permit_default_key_pair_login")
705-
ctx := context.WithValue(context.TODO(), logIdKey, logId)
706-
service := LightHouseService{client: meta.(*TencentCloudClient).apiV3Conn}
707-
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
708-
e := service.ModifyInstancesLoginKeyPairAttribute(ctx, id, new.(string))
709-
if e != nil {
710-
return retryError(e)
711-
}
712-
return nil
713-
})
714-
if err != nil {
715-
log.Printf("[CRITAL]%s update lighthouse instanceLoginKeyPair failed, reason:%+v", logId, err)
716-
return err
717-
}
718-
}
719-
720678
return resourceTencentCloudLighthouseInstanceRead(d, meta)
721679
}
722680

tencentcloud/service_tencentcloud_lighthouse.go

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,56 +1139,6 @@ func (me *LightHouseService) DeleteLighthouseKeyPairAttachmentById(ctx context.C
11391139
return
11401140
}
11411141

1142-
func (me *LightHouseService) DescribeLighthouseInstanceLoginKeyPairById(ctx context.Context, instanceId string) (instanceLoginKeyPair *lighthouse.DescribeInstanceLoginKeyPairAttributeResponseParams, errRet error) {
1143-
logId := getLogId(ctx)
1144-
1145-
request := lighthouse.NewDescribeInstanceLoginKeyPairAttributeRequest()
1146-
request.InstanceId = &instanceId
1147-
1148-
defer func() {
1149-
if errRet != nil {
1150-
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error())
1151-
}
1152-
}()
1153-
1154-
ratelimit.Check(request.GetAction())
1155-
1156-
response, err := me.client.UseLighthouseClient().DescribeInstanceLoginKeyPairAttribute(request)
1157-
if err != nil {
1158-
errRet = err
1159-
return
1160-
}
1161-
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
1162-
1163-
instanceLoginKeyPair = response.Response
1164-
return
1165-
}
1166-
1167-
func (me *LightHouseService) ModifyInstancesLoginKeyPairAttribute(ctx context.Context, instanceId string, permitLogin string) (errRet error) {
1168-
logId := getLogId(ctx)
1169-
1170-
request := lighthouse.NewModifyInstancesLoginKeyPairAttributeRequest()
1171-
request.InstanceIds = []*string{&instanceId}
1172-
request.PermitLogin = helper.String(permitLogin)
1173-
1174-
defer func() {
1175-
if errRet != nil {
1176-
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error())
1177-
}
1178-
}()
1179-
1180-
ratelimit.Check(request.GetAction())
1181-
1182-
response, err := me.client.UseLighthouseClient().ModifyInstancesLoginKeyPairAttribute(request)
1183-
if err != nil {
1184-
errRet = err
1185-
return
1186-
}
1187-
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
1188-
1189-
return
1190-
}
1191-
11921142
func (me *LightHouseService) IsolateLighthouseDiskById(ctx context.Context, diskId string) (errRet error) {
11931143
logId := getLogId(ctx)
11941144

website/docs/r/lighthouse_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The following arguments are supported:
9696
* `is_update_bundle_id_auto_voucher` - (Optional, Bool) Whether the voucher is deducted automatically when update bundle id. Value range: `true`: indicates automatic deduction of vouchers, `false`: does not automatically deduct vouchers. Default value: `false`.
9797
* `isolate_data_disk` - (Optional, Bool) Whether to return the mounted data disk. `true`: returns both the instance and the mounted data disk; `false`: returns the instance and no longer returns its mounted data disk. Default: `true`.
9898
* `login_configuration` - (Optional, List) Login password of the instance. It is only available for Windows instances. If it is not specified, it means that the user choose to set the login password after the instance creation.
99-
* `permit_default_key_pair_login` - (Optional, String, **Deprecated**) It will be deprecated. Use `tencentcloud_lighthouse_key_pair_attachment` manage key pair. Whether to allow login using the default key pair. `YES`: allow login; `NO`: disable login. Default: `YES`.
99+
* `permit_default_key_pair_login` - (Optional, String, **Deprecated**) It has been deprecated from version v1.81.8. Use `tencentcloud_lighthouse_key_pair_attachment` manage key pair. Whether to allow login using the default key pair. `YES`: allow login; `NO`: disable login. Default: `YES`.
100100
* `zone` - (Optional, String) List of availability zones. A random AZ is selected by default.
101101

102102
The `containers` object supports the following:

0 commit comments

Comments
 (0)