Skip to content

Commit

Permalink
modify cen_bandwidth_package
Browse files Browse the repository at this point in the history
  • Loading branch information
SanfordLuo committed Jul 29, 2020
1 parent 60cc61b commit 45bc5db
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
27 changes: 27 additions & 0 deletions alicloud/resource_alicloud_cen_bandwidth_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ func resourceAlicloudCenBandwidthPackage() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"auto_renew": {
Type: schema.TypeBool,
Optional: true,
Default: false,
ForceNew: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return PayType(d.Get("charge_type").(string)) == PrePaid
},
},

"auto_renew_duration": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
ForceNew: true,
ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 6, 12}),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return PayType(d.Get("charge_type").(string)) == PrePaid
},
},
},
}
}
Expand Down Expand Up @@ -295,6 +316,12 @@ func buildAliCloudCenBandwidthPackageArgs(d *schema.ResourceData, meta interface
changeType = "PREPAY"
request.Period = requests.NewInteger(d.Get("period").(int))
request.PricingCycle = "Month"
if v, ok := d.GetOk("auto_renew"); ok {
request.AutoRenew = requests.NewBoolean(v.(bool))
}
if v, ok := d.GetOk("auto_renew_duration"); ok {
request.AutoRenewDuration = requests.NewInteger(v.(int))
}
}

request.BandwidthPackageChargeType = changeType
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/cen_bandwidth_package.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: |-

Provides a CEN bandwidth package resource. The CEN bandwidth package is an abstracted object that includes an interconnection bandwidth and interconnection areas. To buy a bandwidth package, you must specify the areas to connect. An area consists of one or more Alibaba Cloud regions. The areas in CEN include Mainland China, Asia Pacific, North America, and Europe.

For information about CEN and how to use it, see [Manage bandwidth packages](https://www.alibabacloud.com/help/doc-detail/65982.htm).
For information about CEN and how to use it, see [Manage bandwidth packages](https://www.alibabacloud.com/help/en/doc-detail/65982.htm).

## Example Usage

Expand All @@ -36,6 +36,8 @@ The following arguments are supported:
* `description` - (Optional) The description of the bandwidth package. Default to null.
* `charge_type` - (Optional) The billing method. Valid value: PostPaid | PrePaid. Default to PostPaid. If set to PrePaid, the bandwidth package can't be deleted before expired time.
* `period` - (Optional) The purchase period in month. Valid value: 1, 2, 3, 6, 12. Default to 1.
* `auto_renew` - (Optional, ForceNew) Whether to renew a bandwidth package automatically or not. It is valid when `charge_type` is `PrePaid`. Valid value: true, false. Default to `false`.
* `auto_renew_duration` - (Optional, ForceNew) Auto renewal period of an instance, in the unit of month. It is valid when `charge_type` is `PrePaid`. Valid value: 1, 2, 3, 6, 12. Default to `1`.

->**NOTE:** PrePaid mode will deduct fees from the account directly and the bandwidth package can't be deleted before expired time.

Expand Down

0 comments on commit 45bc5db

Please sign in to comment.