Skip to content

Commit 9acdcd3

Browse files
tongyimingmikatong
andauthored
fix: eip read not support internet_charge_type (#1240)
* fix: eip read not support internet_charge_type * update Co-authored-by: mikatong <mikatong@tencent.com>
1 parent df1022a commit 9acdcd3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tencentcloud/resource_tc_eip.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func resourceTencentCloudEip() *schema.Resource {
8080
"internet_charge_type": {
8181
Type: schema.TypeString,
8282
Optional: true,
83+
Computed: true,
8384
ForceNew: true,
8485
ValidateFunc: validateAllowedStringValue(CVM_INTERNET_CHARGE_TYPE),
8586
Description: "The charge type of eip. Valid value: `BANDWIDTH_PACKAGE`, `BANDWIDTH_POSTPAID_BY_HOUR` and `TRAFFIC_POSTPAID_BY_HOUR`.",
@@ -241,6 +242,7 @@ func resourceTencentCloudEipRead(d *schema.ResourceData, meta interface{}) error
241242
_ = d.Set("type", eip.AddressType)
242243
_ = d.Set("public_ip", eip.AddressIp)
243244
_ = d.Set("status", eip.AddressStatus)
245+
_ = d.Set("internet_charge_type", eip.InternetChargeType)
244246
_ = d.Set("tags", tags)
245247
return nil
246248
}

tencentcloud/resource_tc_eip_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,29 @@ func TestAccTencentCloudEip_bandwidth(t *testing.T) {
187187
})
188188
}
189189

190+
func TestAccTencentCloudEip_chargetype(t *testing.T) {
191+
t.Parallel()
192+
resource.Test(t, resource.TestCase{
193+
PreCheck: func() { testAccPreCheck(t) },
194+
Providers: testAccProviders,
195+
CheckDestroy: testAccCheckEipDestroy,
196+
Steps: []resource.TestStep{
197+
{
198+
Config: testAccEipChargeType,
199+
Check: resource.ComposeTestCheckFunc(
200+
testAccCheckEipExists("tencentcloud_eip.foo"),
201+
resource.TestCheckResourceAttr("tencentcloud_eip.foo", "internet_charge_type", "TRAFFIC_POSTPAID_BY_HOUR"),
202+
),
203+
},
204+
{
205+
ResourceName: "tencentcloud_eip.foo",
206+
ImportState: true,
207+
ImportStateVerify: true,
208+
},
209+
},
210+
})
211+
}
212+
190213
func testAccCheckEipExists(n string) resource.TestCheckFunc {
191214
return func(s *terraform.State) error {
192215
logId := getLogId(contextNil)
@@ -312,3 +335,10 @@ resource "tencentcloud_eip" "foo" {
312335
internet_max_bandwidth_out = 2
313336
}
314337
`
338+
339+
const testAccEipChargeType = `
340+
resource "tencentcloud_eip" "foo" {
341+
name = "eip_charge_type"
342+
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
343+
}
344+
`

0 commit comments

Comments
 (0)