Skip to content

Commit 7c93a93

Browse files
tongyimingmikatong
and
mikatong
authored
fix(clb): [117725810]ipv6 clb support set subnet (#2696)
* ipv6 clb support set subnet * add changelog * update --------- Co-authored-by: mikatong <[email protected]>
1 parent 095e8fe commit 7c93a93

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

.changelog/2696.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_clb_instance: open ipv6 clb support set `subnet_id`
3+
```

tencentcloud/services/clb/resource_tc_clb_instance.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
276276
request.ProjectId = &projectId
277277
}
278278
if v, ok := d.GetOk("subnet_id"); ok {
279-
if networkType == CLB_NETWORK_TYPE_OPEN {
280-
return fmt.Errorf("[CHECK][CLB instance][Create] check: OPEN network_type do not support this operation with subnet_id")
281-
}
282279
request.SubnetId = helper.String(v.(string))
283280
}
284281

@@ -600,7 +597,12 @@ func resourceTencentCloudClbInstanceRead(d *schema.ResourceData, meta interface{
600597
}
601598

602599
if instance.AddressIPVersion != nil {
603-
_ = d.Set("address_ip_version", instance.AddressIPVersion)
600+
if *instance.AddressIPVersion == "ipv6" && instance.IPv6Mode != nil && *instance.IPv6Mode == "IPv6FullChain" {
601+
_ = d.Set("address_ip_version", instance.IPv6Mode)
602+
} else {
603+
_ = d.Set("address_ip_version", instance.AddressIPVersion)
604+
}
605+
604606
}
605607
if instance.NetworkAttributes != nil {
606608
_ = d.Set("internet_bandwidth_max_out", instance.NetworkAttributes.InternetMaxBandwidthOut)

tencentcloud/services/clb/resource_tc_clb_instance_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const InternalClbNameUpdate = "tf-clb-update-internal"
2222
const SingleClbName = "single-open-clb"
2323
const MultiClbName = "multi-open-clb"
2424
const OpenClbName = "tf-clb-open"
25+
const OpenClbNameIpv6 = "tf-clb-open-ipv6"
2526
const OpenClbNameUpdate = "tf-clb-update-open"
2627

2728
func init() {
@@ -158,6 +159,30 @@ func TestAccTencentCloudClbInstanceResource_open(t *testing.T) {
158159
})
159160
}
160161

162+
func TestAccTencentCloudClbInstanceResource_openIpv6(t *testing.T) {
163+
t.Parallel()
164+
165+
resource.Test(t, resource.TestCase{
166+
PreCheck: func() { tcacctest.AccPreCheck(t) },
167+
Providers: tcacctest.AccProviders,
168+
CheckDestroy: testAccCheckClbInstanceDestroy,
169+
Steps: []resource.TestStep{
170+
{
171+
Config: testAccClbInstance_openIpv6,
172+
Check: resource.ComposeTestCheckFunc(
173+
testAccCheckClbInstanceExists("tencentcloud_clb_instance.clb_open_ipv6"),
174+
resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open_ipv6", "network_type", "OPEN"),
175+
resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open_ipv6", "clb_name", OpenClbNameIpv6),
176+
resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open_ipv6", "project_id", "0"),
177+
resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open_ipv6", "vpc_id", "vpc-mvhjjprd"),
178+
resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open_ipv6", "subnet_id", "subnet-2qfyfvv8"),
179+
resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open_ipv6", "address_ip_version", "IPv6FullChain"),
180+
),
181+
},
182+
},
183+
})
184+
}
185+
161186
func TestAccTencentCloudClbInstanceResource_snat(t *testing.T) {
162187
t.Parallel()
163188

@@ -629,3 +654,14 @@ resource "tencentcloud_clb_instance" "multiple_instance" {
629654
}
630655
}
631656
`
657+
658+
const testAccClbInstance_openIpv6 = `
659+
resource "tencentcloud_clb_instance" "clb_open_ipv6" {
660+
clb_name = "` + OpenClbNameIpv6 + `"
661+
network_type = "OPEN"
662+
project_id = 0
663+
vpc_id = "vpc-mvhjjprd"
664+
subnet_id = "subnet-2qfyfvv8"
665+
address_ip_version = "IPv6FullChain"
666+
}
667+
`

0 commit comments

Comments
 (0)