Skip to content

Commit b0bd09c

Browse files
authored
Merge pull request #461 from oliverpei/master
fix cvm allocate_public_ip inconsistency when eip is attached to the cvm
2 parents 5e886be + cb30de4 commit b0bd09c

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## 1.39.0 (Unreleased)
1+
## 1.38.2 (Unreleased)
2+
3+
BUG FIXES:
4+
5+
* Resource: `tencentcloud_instance` fix `allocate_public_ip` inconsistency when eip is attached to the cvm.
6+
27
## 1.38.1 (June 30, 2020)
38

49
BUG FIXES:

tencentcloud/resource_tc_instance.go

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ import (
8787
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
8888
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
8989
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
90-
vpc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312"
9190
"github.com/terraform-providers/terraform-provider-tencentcloud/tencentcloud/internal/helper"
9291
"github.com/terraform-providers/terraform-provider-tencentcloud/tencentcloud/ratelimit"
9392
)
@@ -695,26 +694,8 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
695694
_ = d.Set("create_time", instance.CreatedTime)
696695
_ = d.Set("expired_time", instance.ExpiredTime)
697696

698-
if len(instance.PublicIpAddresses) > 0 {
699-
vpcService := VpcService{client: client}
700-
filter := map[string][]string{
701-
"address-ip": {*instance.PublicIpAddresses[0]},
702-
}
703-
var eips []*vpc.Address
704-
var errRet error
705-
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
706-
eips, errRet = vpcService.DescribeEipByFilter(ctx, filter)
707-
if errRet != nil {
708-
return retryError(errRet, InternalError)
709-
}
710-
return nil
711-
})
712-
if err != nil {
713-
return err
714-
}
715-
_ = d.Set("allocate_public_ip", len(eips) < 1)
716-
} else {
717-
_ = d.Set("allocate_public_ip", false)
697+
if _, ok := d.GetOkExists("allocate_public_ip"); !ok {
698+
_ = d.Set("allocate_public_ip", len(instance.PublicIpAddresses) > 0)
718699
}
719700

720701
// as attachment add tencentcloud:autoscaling:auto-scaling-group-id tag automatically

0 commit comments

Comments
 (0)