Skip to content

Commit 50805fc

Browse files
author
ivan
committed
添加terraform支持external CLB创建AZ实例
1 parent d0ba33b commit 50805fc

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tencentcloud/resource_tc_clb_instance.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,21 @@ func resourceTencentCloudClbInstance() *schema.Resource {
165165
Default: true,
166166
Description: "Whether the target allow flow come from clb. If value is true, only check security group of clb, or check both clb and backend instance security group.",
167167
},
168+
"master_zone_id": {
169+
Type: schema.TypeString,
170+
Optional: true,
171+
Description: "Setting master zone id of cross available zone disaster recovery, only applicable to open CLB.",
172+
},
173+
"zone_id": {
174+
Type: schema.TypeString,
175+
Optional: true,
176+
Description: "Available zone id, only applicable to open CLB.",
177+
},
178+
"slave_zone_id": {
179+
Type: schema.TypeString,
180+
Optional: true,
181+
Description: "Setting slave zone id of cross available zone disaster recovery, only applicable to open CLB. this zone will undertake traffic when the master is down",
182+
},
168183
},
169184
}
170185
}
@@ -254,6 +269,26 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
254269
}
255270
}
256271

272+
if v, ok := d.GetOk("master_zone_id"); ok {
273+
if networkType == CLB_NETWORK_TYPE_INTERNAL {
274+
return fmt.Errorf("[CHECK][CLB instance][Create] check: INTERNAL network_type do not support master zone id setting")
275+
}
276+
request.MasterZoneId = helper.String(v.(string))
277+
}
278+
279+
if v, ok := d.GetOk("zone_id"); ok {
280+
if networkType == CLB_NETWORK_TYPE_INTERNAL {
281+
return fmt.Errorf("[CHECK][CLB instance][Create] check: INTERNAL network_type do not support zone id setting")
282+
}
283+
request.ZoneId = helper.String(v.(string))
284+
}
285+
286+
if v, ok := d.GetOk("slave_zone_id"); ok {
287+
if networkType == CLB_NETWORK_TYPE_INTERNAL {
288+
return fmt.Errorf("[CHECK][CLB instance][Create] check: INTERNAL network_type do not support slave zone id setting")
289+
}
290+
request.SlaveZoneId = helper.String(v.(string))
291+
}
257292
clbId := ""
258293
var response *clb.CreateLoadBalancerResponse
259294
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
@@ -406,6 +441,10 @@ func resourceTencentCloudClbInstanceRead(d *schema.ResourceData, meta interface{
406441
_ = d.Set("internet_charge_type", instance.NetworkAttributes.InternetChargeType)
407442
}
408443

444+
_ = d.Set("master_zone_id", instance.MasterZone)
445+
_ = d.Set("zone_id", instance.MasterZone)
446+
_ = d.Set("slave_zone_id", instance.MasterZone)
447+
409448
tcClient := meta.(*TencentCloudClient).apiV3Conn
410449
tagService := &TagService{client: tcClient}
411450
tags, err := tagService.DescribeResourceTags(ctx, "clb", "clb", tcClient.Region, d.Id())

0 commit comments

Comments
 (0)