Skip to content

Commit 0c45d69

Browse files
authored
add clb vip (#2485)
* add clb vip * add changelog
1 parent a419305 commit 0c45d69

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed

.changelog/2485.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: Support set specified `vip`
3+
```

tencentcloud/services/clb/resource_tc_clb_instance.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ func ResourceTencentCloudClbInstance() *schema.Resource {
168168
Computed: true,
169169
Description: "Network operator, only applicable to open CLB. Valid values are `CMCC`(China Mobile), `CTCC`(Telecom), `CUCC`(China Unicom) and `BGP`. If this ISP is specified, network billing method can only use the bandwidth package billing (BANDWIDTH_PACKAGE).",
170170
},
171+
"vip": {
172+
Type: schema.TypeString,
173+
Optional: true,
174+
ForceNew: true,
175+
Computed: true,
176+
Description: "Applies for CLB instances for a specified VIP, only applicable to open CLB.",
177+
},
171178
"load_balancer_pass_to_target": {
172179
Type: schema.TypeBool,
173180
Optional: true,
@@ -265,14 +272,22 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
265272
request.SubnetId = helper.String(v.(string))
266273
}
267274

268-
//vip
275+
//vip_isp
269276
if v, ok := d.GetOk("vip_isp"); ok {
270277
if networkType == CLB_NETWORK_TYPE_INTERNAL {
271278
return fmt.Errorf("[CHECK][CLB instance][Create] check: INTERNAL network_type do not support vip ISP setting")
272279
}
273280
request.VipIsp = helper.String(v.(string))
274281
}
275282

283+
//vip
284+
if v, ok := d.GetOk("vip"); ok {
285+
if networkType == CLB_NETWORK_TYPE_INTERNAL {
286+
return fmt.Errorf("[CHECK][CLB instance][Create] check: INTERNAL network_type do not support vip setting")
287+
}
288+
request.Vip = helper.String(v.(string))
289+
}
290+
276291
//SlaType
277292
if v, ok := d.GetOk("sla_type"); ok {
278293
request.SlaType = helper.String(v.(string))
@@ -570,6 +585,11 @@ func resourceTencentCloudClbInstanceRead(d *schema.ResourceData, meta interface{
570585
if instance.VipIsp != nil {
571586
_ = d.Set("vip_isp", instance.VipIsp)
572587
}
588+
589+
if instance.LoadBalancerVips != nil && len(instance.LoadBalancerVips) > 0 {
590+
_ = d.Set("vip", instance.LoadBalancerVips[0])
591+
}
592+
573593
if instance.AddressIPVersion != nil {
574594
_ = d.Set("address_ip_version", instance.AddressIPVersion)
575595
}

tencentcloud/services/clb/resource_tc_clb_instance.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,37 @@ output "domain" {
116116
}
117117
```
118118

119+
Specified Vip Instance
120+
121+
```hcl
122+
resource "tencentcloud_security_group" "foo" {
123+
name = "clb-instance-open-sg"
124+
}
125+
126+
resource "tencentcloud_vpc" "foo" {
127+
name = "clb-instance-open-vpc"
128+
cidr_block = "10.0.0.0/16"
129+
}
130+
131+
resource "tencentcloud_clb_instance" "clb_open" {
132+
network_type = "OPEN"
133+
clb_name = "clb-instance-open"
134+
project_id = 0
135+
vpc_id = tencentcloud_vpc.foo.id
136+
security_groups = [tencentcloud_security_group.foo.id]
137+
138+
vip = "111.230.4.204"
139+
140+
tags = {
141+
test = "tf"
142+
}
143+
}
144+
145+
output "domain" {
146+
value = tencentcloud_clb_instance.vip
147+
}
148+
```
149+
119150
Default enable
120151

121152
```hcl

website/docs/r/clb_instance.html.markdown

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,37 @@ output "domain" {
127127
}
128128
```
129129

130+
### Specified Vip Instance
131+
132+
```hcl
133+
resource "tencentcloud_security_group" "foo" {
134+
name = "clb-instance-open-sg"
135+
}
136+
137+
resource "tencentcloud_vpc" "foo" {
138+
name = "clb-instance-open-vpc"
139+
cidr_block = "10.0.0.0/16"
140+
}
141+
142+
resource "tencentcloud_clb_instance" "clb_open" {
143+
network_type = "OPEN"
144+
clb_name = "clb-instance-open"
145+
project_id = 0
146+
vpc_id = tencentcloud_vpc.foo.id
147+
security_groups = [tencentcloud_security_group.foo.id]
148+
149+
vip = "111.230.4.204"
150+
151+
tags = {
152+
test = "tf"
153+
}
154+
}
155+
156+
output "domain" {
157+
value = tencentcloud_clb_instance.vip
158+
}
159+
```
160+
130161
### Default enable
131162

132163
```hcl
@@ -253,6 +284,7 @@ The following arguments are supported:
253284
* `target_region_info_region` - (Optional, String) Region information of backend services are attached the CLB instance. Only supports `OPEN` CLBs.
254285
* `target_region_info_vpc_id` - (Optional, String) Vpc information of backend services are attached the CLB instance. Only supports `OPEN` CLBs.
255286
* `vip_isp` - (Optional, String, ForceNew) Network operator, only applicable to open CLB. Valid values are `CMCC`(China Mobile), `CTCC`(Telecom), `CUCC`(China Unicom) and `BGP`. If this ISP is specified, network billing method can only use the bandwidth package billing (BANDWIDTH_PACKAGE).
287+
* `vip` - (Optional, String, ForceNew) Applies for CLB instances for a specified VIP, only applicable to open CLB.
256288
* `vpc_id` - (Optional, String, ForceNew) VPC ID of the CLB.
257289
* `zone_id` - (Optional, String) Available zone id, only applicable to open CLB.
258290

0 commit comments

Comments
 (0)