Skip to content

Commit 5259ba9

Browse files
committed
add
1 parent fd00d50 commit 5259ba9

11 files changed

+474
-320
lines changed

tencentcloud/services/cvm/resource_tc_cvm_renew_instance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func ResourceTencentCloudCvmRenewInstance() *schema.Resource {
4141
"renew_flag": {
4242
Type: schema.TypeString,
4343
Optional: true,
44-
Description: "Auto renewal flag. Valid values:<br><li>NOTIFY_AND_AUTO_RENEW: notify upon expiration and renew automatically<br><li>NOTIFY_AND_MANUAL_RENEW: notify upon expiration but do not renew automatically<br><li>DISABLE_NOTIFY_AND_MANUAL_RENEW: neither notify upon expiration nor renew automatically<br><br>Default value: NOTIFY_AND_MANUAL_RENEW. If this parameter is specified as NOTIFY_AND_AUTO_RENEW, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. Note: This field may return null, indicating that no valid value is found.",
44+
Description: "Auto renewal flag. Valid values:<br><li>NOTIFY_AND_AUTO_RENEWnotify upon expiration and renew automatically<br><li>NOTIFY_AND_MANUAL_RENEWnotify upon expiration but do not renew automatically<br><li>DISABLE_NOTIFY_AND_MANUAL_RENEWneither notify upon expiration nor renew automatically<br><br>Default value: NOTIFY_AND_MANUAL_RENEWIf this parameter is specified as NOTIFY_AND_AUTO_RENEW, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. Note: This field may return null, indicating that no valid value is found.",
4545
},
4646
},
4747
},
@@ -51,7 +51,7 @@ func ResourceTencentCloudCvmRenewInstance() *schema.Resource {
5151
Type: schema.TypeBool,
5252
Optional: true,
5353
ForceNew: true,
54-
Description: "Whether to renew the elastic data disk. Valid values:<br><li>TRUE: Indicates to renew the subscription instance and renew the attached elastic data disk at the same time<br><li>FALSE: Indicates that the subscription instance will be renewed and the elastic data disk attached to it will not be renewed<br><br>Default value: TRUE.",
54+
Description: "Whether to renew the elastic data disk. Valid values:<br><li>TRUEIndicates to renew the subscription instance and renew the attached elastic data disk at the same time<br><li>FALSEIndicates that the subscription instance will be renewed and the elastic data disk attached to it will not be renewed<br><br>Default valueTRUE.",
5555
},
5656
},
5757
}

tencentcloud/services/cvm/resource_tc_cvm_security_group_attachment.go

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -94,38 +94,38 @@ func resourceTencentCloudCvmSecurityGroupAttachmentRead(d *schema.ResourceData,
9494
defer tccommon.LogElapsed("resource.tencentcloud_cvm_security_group_attachment.read")()
9595
defer tccommon.InconsistentCheck(d, meta)()
9696

97-
//logId := tccommon.GetLogId(tccommon.ContextNil)
98-
//
99-
//ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
100-
//
101-
//service := CvmService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
102-
//
103-
//idSplit := strings.Split(d.Id(), tccommon.FILED_SP)
104-
//if len(idSplit) != 2 {
105-
// return fmt.Errorf("id is broken,%s", d.Id())
106-
//}
107-
//instanceId := idSplit[0]
108-
//securityGroupId := idSplit[1]
109-
//
110-
//_ = d.Set("instance_id", instanceId)
111-
//
112-
//_ = d.Set("security_group_id", securityGroupId)
113-
114-
//respData, err := service.DescribeCvmSecurityGroupAttachmentById(ctx, instanceId)
115-
//if err != nil {
116-
// return err
117-
//}
118-
//
119-
//if respData == nil {
120-
// d.SetId("")
121-
// log.Printf("[WARN]%s resource `cvm_security_group_attachment` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
122-
// return nil
123-
//}
124-
//if err := resourceTencentCloudCvmSecurityGroupAttachmentReadPostHandleResponse0(ctx, respData); err != nil {
125-
// return err
126-
//}
127-
//
128-
//_ = securityGroupId
97+
logId := tccommon.GetLogId(tccommon.ContextNil)
98+
99+
ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
100+
101+
service := CvmService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
102+
103+
idSplit := strings.Split(d.Id(), tccommon.FILED_SP)
104+
if len(idSplit) != 2 {
105+
return fmt.Errorf("id is broken,%s", d.Id())
106+
}
107+
instanceId := idSplit[0]
108+
securityGroupId := idSplit[1]
109+
110+
_ = d.Set("instance_id", instanceId)
111+
112+
_ = d.Set("security_group_id", securityGroupId)
113+
114+
respData, err := service.DescribeCvmSecurityGroupAttachmentById(ctx, instanceId)
115+
if err != nil {
116+
return err
117+
}
118+
119+
if respData == nil {
120+
d.SetId("")
121+
log.Printf("[WARN]%s resource `cvm_security_group_attachment` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
122+
return nil
123+
}
124+
if err := resourceTencentCloudCvmSecurityGroupAttachmentReadPostHandleResponse0(ctx, respData); err != nil {
125+
return err
126+
}
127+
128+
_ = securityGroupId
129129
return nil
130130
}
131131

@@ -163,10 +163,11 @@ func resourceTencentCloudCvmSecurityGroupAttachmentDelete(d *schema.ResourceData
163163
return nil
164164
})
165165
if err != nil {
166-
log.Printf("[CRITAL]%s create cvm security group attachment failed, reason:%+v", logId, err)
166+
log.Printf("[CRITAL]%s delete cvm security group attachment failed, reason:%+v", logId, err)
167167
return err
168168
}
169169

170170
_ = response
171+
_ = securityGroupId
171172
return nil
172173
}

tencentcloud/services/cvm/resource_tc_cvm_security_group_attachment_extension.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,28 @@ import (
55
"fmt"
66
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
77
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
8+
"log"
89
"strings"
910
)
1011

11-
func resourceTencentCloudCvmSecurityGroupAttachmentReadPostHandleResponse0(ctx context.Context, resp *cvm.Instance) error {
12+
func resourceTencentCloudCvmSecurityGroupAttachmentReadPostHandleResponse0(ctx context.Context, resp *cvm.DescribeInstancesResponseParams) error {
1213
d := tccommon.ResourceDataFromContext(ctx)
14+
logId := tccommon.GetLogId(tccommon.ContextNil)
15+
if len(resp.InstanceSet) < 1 {
16+
d.SetId("")
17+
log.Printf("[WARN]%s resource `CvmSecurityGroupAttachment` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
18+
return nil
19+
}
20+
1321
idSplit := strings.Split(d.Id(), tccommon.FILED_SP)
1422
if len(idSplit) != 2 {
1523
return fmt.Errorf("id is broken,%s", d.Id())
1624
}
1725
instanceId := idSplit[0]
1826
securityGroupId := idSplit[1]
1927

20-
for _, sgId := range resp.SecurityGroupIds {
28+
instanceInfo := resp.InstanceSet[0]
29+
for _, sgId := range instanceInfo.SecurityGroupIds {
2130
if *sgId == securityGroupId {
2231
_ = d.Set("instance_id", instanceId)
2332
_ = d.Set("security_group_id", securityGroupId)

tencentcloud/services/cvm/resource_tc_cvm_sync_image.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func ResourceTencentCloudCvmSyncImage() *schema.Resource {
1717
Create: resourceTencentCloudCvmSyncImageCreate,
1818
Read: resourceTencentCloudCvmSyncImageRead,
1919
Delete: resourceTencentCloudCvmSyncImageDelete,
20-
2120
Schema: map[string]*schema.Schema{
2221
"destination_regions": {
2322
Type: schema.TypeSet,

tencentcloud/services/cvm/resource_tc_eip_address_transform.go

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package cvm
22

33
import (
4+
"context"
45
"log"
5-
"time"
6-
7-
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
8-
svcvpc "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/vpc"
96

107
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
118
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
12-
eip "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312"
9+
vpc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312"
1310

11+
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
1412
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
1513
)
1614

@@ -19,12 +17,11 @@ func ResourceTencentCloudEipAddressTransform() *schema.Resource {
1917
Create: resourceTencentCloudEipAddressTransformCreate,
2018
Read: resourceTencentCloudEipAddressTransformRead,
2119
Delete: resourceTencentCloudEipAddressTransformDelete,
22-
2320
Schema: map[string]*schema.Schema{
2421
"instance_id": {
22+
Type: schema.TypeString,
2523
Required: true,
2624
ForceNew: true,
27-
Type: schema.TypeString,
2825
Description: "the instance ID of a normal public network IP to be operated. eg:ins-23mk45jn.",
2926
},
3027
},
@@ -37,18 +34,26 @@ func resourceTencentCloudEipAddressTransformCreate(d *schema.ResourceData, meta
3734

3835
logId := tccommon.GetLogId(tccommon.ContextNil)
3936

37+
ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
38+
4039
var (
41-
request = eip.NewTransformAddressRequest()
42-
response = eip.NewTransformAddressResponse()
4340
instanceId string
4441
)
42+
var (
43+
request = vpc.NewTransformAddressRequest()
44+
response = vpc.NewTransformAddressResponse()
45+
)
46+
4547
if v, ok := d.GetOk("instance_id"); ok {
4648
instanceId = v.(string)
49+
}
50+
51+
if v, ok := d.GetOk("instance_id"); ok {
4752
request.InstanceId = helper.String(v.(string))
4853
}
4954

5055
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
51-
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().TransformAddress(request)
56+
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().TransformAddressWithContext(ctx, request)
5257
if e != nil {
5358
return tccommon.RetryError(e)
5459
} else {
@@ -58,21 +63,18 @@ func resourceTencentCloudEipAddressTransformCreate(d *schema.ResourceData, meta
5863
return nil
5964
})
6065
if err != nil {
61-
log.Printf("[CRITAL]%s operate eip addressTransform failed, reason:%+v", logId, err)
66+
log.Printf("[CRITAL]%s create eip address transform failed, reason:%+v", logId, err)
6267
return err
6368
}
6469

65-
taskId := *response.Response.TaskId
66-
d.SetId(instanceId)
67-
68-
service := svcvpc.NewVpcService(meta.(tccommon.ProviderMeta).GetAPIV3Conn())
70+
_ = response
6971

70-
conf := tccommon.BuildStateChangeConf([]string{}, []string{"SUCCESS"}, 1*tccommon.ReadRetryTimeout, time.Second, service.VpcIpv6AddressStateRefreshFunc(helper.UInt64ToStr(taskId), []string{}))
71-
72-
if _, e := conf.WaitForState(); e != nil {
73-
return e
72+
if err := resourceTencentCloudEipAddressTransformCreatePostHandleResponse0(ctx, response); err != nil {
73+
return err
7474
}
7575

76+
d.SetId(instanceId)
77+
7678
return resourceTencentCloudEipAddressTransformRead(d, meta)
7779
}
7880

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cvm
2+
3+
import (
4+
"context"
5+
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
6+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
7+
svcvpc "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/vpc"
8+
"time"
9+
10+
vpc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312"
11+
)
12+
13+
func resourceTencentCloudEipAddressTransformCreatePostHandleResponse0(ctx context.Context, resp *vpc.TransformAddressResponse) error {
14+
meta := tccommon.ProviderMetaFromContext(ctx)
15+
service := svcvpc.NewVpcService(meta.(tccommon.ProviderMeta).GetAPIV3Conn())
16+
17+
taskId := *resp.Response.TaskId
18+
conf := tccommon.BuildStateChangeConf([]string{}, []string{"SUCCESS"}, 1*tccommon.ReadRetryTimeout, time.Second, service.VpcIpv6AddressStateRefreshFunc(helper.UInt64ToStr(taskId), []string{}))
19+
20+
if _, e := conf.WaitForState(); e != nil {
21+
return e
22+
}
23+
24+
return nil
25+
}

0 commit comments

Comments
 (0)