Skip to content

Commit 86ff6ad

Browse files
committed
add
1 parent 5259ba9 commit 86ff6ad

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tencentcloud/services/cvm/resource_tc_eip_association.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log"
66

77
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
8+
89
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
910
)
1011

@@ -112,6 +113,10 @@ func resourceTencentCloudEipAssociationDelete(d *schema.ResourceData, meta inter
112113

113114
eipId := d.Id()
114115

116+
if err := resourceTencentCloudEipAssociationDeleteOnExit(ctx); err != nil {
117+
return err
118+
}
119+
115120
_ = eipId
116121
_ = ctx
117122
return nil

tencentcloud/services/cvm/resource_tc_eip_association_extension.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,32 @@ func resourceTencentCloudEipAssociationReadPreRequest0(ctx context.Context, req
180180
return nil
181181
}
182182

183+
func resourceTencentCloudEipAssociationDeleteOnExit(ctx context.Context) error {
184+
d := tccommon.ResourceDataFromContext(ctx)
185+
id := d.Id()
186+
meta := tccommon.ProviderMetaFromContext(ctx)
187+
vpcService := svcvpc.NewVpcService(meta.(tccommon.ProviderMeta).GetAPIV3Conn())
188+
association, err := ParseEipAssociationId(id)
189+
if err != nil {
190+
return err
191+
}
192+
193+
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
194+
e := vpcService.UnattachEip(ctx, association.EipId)
195+
if e != nil {
196+
return tccommon.RetryError(e, "DesOperation.MutexTaskRunning")
197+
}
198+
199+
return nil
200+
})
201+
202+
if err != nil {
203+
return err
204+
}
205+
206+
return nil
207+
}
208+
183209
func ParseEipAssociationId(associationId string) (association EipAssociationId, errRet error) {
184210
ids := strings.Split(associationId, "::")
185211
if len(ids) < 2 || len(ids) > 3 {

0 commit comments

Comments
 (0)