Skip to content

Commit

Permalink
Modify EIP default to PayByTraffic for international account
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhu36 committed Jan 31, 2018
1 parent eb44d2f commit 649f50f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## 1.8.0 (Unreleased)
## 1.7.1 (Unreleased)

IMPROVEMENTS:

- Modify EIP default to PayByTraffic for international account (([#369](https://github.com/alibaba/terraform-provider/pull/369)))
- Deprecate nat gateway fileds 'spec' and 'bandwidth_packages' ([#368](https://github.com/alibaba/terraform-provider/pull/368))
- Support to associate EIP with SLB and Nat Gateway ([#367](https://github.com/alibaba/terraform-provider/pull/367))

Expand Down
2 changes: 1 addition & 1 deletion alicloud/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
EipIncorrectStatus = "IncorrectEipStatus"
InstanceIncorrectStatus = "IncorrectInstanceStatus"
HaVipIncorrectStatus = "IncorrectHaVipStatus"
EipTaskConflict = "TaskConflict"
COMMODITYINVALID_COMPONENT = "COMMODITY.INVALID_COMPONENT"
// slb
LoadBalancerNotFound = "InvalidLoadBalancerId.NotFound"
UnsupportedProtocalPort = "UnsupportedOperationonfixedprotocalport"
Expand Down
5 changes: 4 additions & 1 deletion alicloud/resource_alicloud_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func resourceAliyunEip() *schema.Resource {
},
"internet_charge_type": &schema.Schema{
Type: schema.TypeString,
Default: "PayByBandwidth",
Default: "PayByTraffic",
Optional: true,
ForceNew: true,
ValidateFunc: validateInternetChargeType,
Expand Down Expand Up @@ -64,6 +64,9 @@ func resourceAliyunEipCreate(d *schema.ResourceData, meta interface{}) error {

_, allocationID, err := conn.AllocateEipAddress(args)
if err != nil {
if IsExceptedError(err, COMMODITYINVALID_COMPONENT) && args.InternetChargeType == common.PayByBandwidth {
return fmt.Errorf("Your account is international and it can only create '%s' elastic IP. Please change it and try again.", common.PayByTraffic)
}
return err
}

Expand Down
9 changes: 4 additions & 5 deletions alicloud/resource_alicloud_eip_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"
"time"

"github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -54,7 +53,7 @@ func resourceAliyunEipAssociationCreate(d *schema.ResourceData, meta interface{}
if err := resource.Retry(3*time.Minute, func() *resource.RetryError {
ar := args
if err := conn.NewAssociateEipAddress(&ar); err != nil {
if IsExceptedError(err, EipTaskConflict) {
if IsExceptedError(err, TaskConflict) {
return resource.RetryableError(fmt.Errorf("AssociateEip got an error: %#v", err))
}
return resource.NonRetryableError(fmt.Errorf("AssociateEip got an error: %#v", err))
Expand Down Expand Up @@ -114,9 +113,9 @@ func resourceAliyunEipAssociationDelete(d *schema.ResourceData, meta interface{}
err := conn.UnassociateEipAddress(allocationId, instanceId)

if err != nil {
e, _ := err.(*common.Error)
errCode := e.ErrorResponse.Code
if errCode == InstanceIncorrectStatus || errCode == HaVipIncorrectStatus {
if IsExceptedError(err, InstanceIncorrectStatus) ||
IsExceptedError(err, HaVipIncorrectStatus) ||
IsExceptedError(err, TaskConflict) {
return resource.RetryableError(fmt.Errorf("Unassociat EIP timeout and got an error:%#v.", err))
}
}
Expand Down

0 comments on commit 649f50f

Please sign in to comment.