Skip to content

Commit c9ae243

Browse files
author
ivan
committed
添加支持 clb 创建目标工作组的逻辑,添加相应函数的参数 修复新添加的命令行参数错误,Elem字段使用 schema.Resource指针 添加安全组对内网clb的支持(注释掉对当前网络是否为内网的判断) 添加支持开启和关闭CLB安全组默认放通的配置 添加terraform支持external CLB创建AZ实例 添加clb创建目标工作组中,调用create后的update操作中的 port 字段 添加create中调用update操作时,设置load_balancer_pass_to_target 修改在 resourceTencentCloudClbInstanceUpdate 中对 LoadBalancerPassToTarget 取值的处理,修复 tf 文件该值有变化时,没有触发更改的问题 修改支持internal CLB的security group 中description注释部分 添加调用 CreateClusterInstances时,传入imageId参数来指定镜像,以及对镜像的验证,满足 img-xxx 的格式 回退版本(添加镜像),该文件不再维护 修改命令行参数的key, os -> img_id 修改tke资源is_non_static_ip_mode描述不当的错误, static -> non-static 添加Update操作对Port的支持 需求 支持external CLB创建多AZ实例 Description添加master_zone及查询结果相应的字段 添加测试用命,及 hcl 测试说明文档注释 添加测试用命,及 hcl 测试说明文档注释 添加创建多实例,开启和关闭CLB安全组默认放通测试用例 完善测试文件 添加AS的参数 MultiZoneSubnetPolicy ,支持多可用区(子网)打散 gendoc change changelog.md
1 parent aacbd13 commit c9ae243

22 files changed

+561
-55
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
## 1.56.9 (Unreleased)
2+
## 1.56.10 (Jun 09, 2021)
3+
4+
BUG FIXES:
5+
6+
* Resource `tencentcloud_instance` fix words spell, in tencendcloud/resource_tc_instance.go L45, data.tencentcloud_availability_zones.my_favorate_zones.zones.0.name change to data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name".
7+
* Resource `tencentcloud_kubernetes_clusters` fix the description of is_non_static_ip_mode
8+
9+
ENHANCEMENTS:
10+
11+
* Resource `tencentcloud_clb_target_group` add create target group.
12+
* Resource `tencentcloud_clb_instance` add internal CLB supports security group.
13+
* Resource `tencentcloud_clb_instance` add supports open and close CLB security group, default is open.
14+
* Resource `tencentcloud_clb_instance` add external CLB create multi AZ instance.
15+
* Resource `tencentcloud_container_cluster_instance` add supports params of img_id to assign image.
16+
* Resource `tencentcloud_as_scaling_group` add MultiZoneSubnetPolicy.
17+
218
## 1.56.8 (May 26, 2021)
319

420
ENHANCEMENTS:

tencentcloud/data_source_tc_as_scaling_groups.go

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ func dataSourceTencentCloudAsScalingGroups() *schema.Resource {
196196
Computed: true,
197197
Description: "Tags of the scaling group.",
198198
},
199+
"multi_zone_subnet_policy": {
200+
Type: schema.TypeString,
201+
Computed: true,
202+
Description: "Multi zone or subnet strategy, Valid values: PRIORITY and EQUALITY.",
203+
},
199204
},
200205
},
201206
},
@@ -241,23 +246,24 @@ func dataSourceTencentCloudAsScalingGroupRead(d *schema.ResourceData, meta inter
241246
}
242247

243248
mapping := map[string]interface{}{
244-
"scaling_group_id": scalingGroup.AutoScalingGroupId,
245-
"scaling_group_name": scalingGroup.AutoScalingGroupName,
246-
"configuration_id": scalingGroup.LaunchConfigurationId,
247-
"status": scalingGroup.AutoScalingGroupStatus,
248-
"instance_count": scalingGroup.InstanceCount,
249-
"max_size": scalingGroup.MaxSize,
250-
"min_size": scalingGroup.MinSize,
251-
"vpc_id": scalingGroup.VpcId,
252-
"subnet_ids": helper.StringsInterfaces(scalingGroup.SubnetIdSet),
253-
"zones": helper.StringsInterfaces(scalingGroup.ZoneSet),
254-
"default_cooldown": scalingGroup.DefaultCooldown,
255-
"desired_capacity": scalingGroup.DesiredCapacity,
256-
"load_balancer_ids": helper.StringsInterfaces(scalingGroup.LoadBalancerIdSet),
257-
"termination_policies": helper.StringsInterfaces(scalingGroup.TerminationPolicySet),
258-
"retry_policy": scalingGroup.RetryPolicy,
259-
"create_time": scalingGroup.CreatedTime,
260-
"tags": tags,
249+
"scaling_group_id": scalingGroup.AutoScalingGroupId,
250+
"scaling_group_name": scalingGroup.AutoScalingGroupName,
251+
"configuration_id": scalingGroup.LaunchConfigurationId,
252+
"status": scalingGroup.AutoScalingGroupStatus,
253+
"instance_count": scalingGroup.InstanceCount,
254+
"max_size": scalingGroup.MaxSize,
255+
"min_size": scalingGroup.MinSize,
256+
"vpc_id": scalingGroup.VpcId,
257+
"subnet_ids": helper.StringsInterfaces(scalingGroup.SubnetIdSet),
258+
"zones": helper.StringsInterfaces(scalingGroup.ZoneSet),
259+
"default_cooldown": scalingGroup.DefaultCooldown,
260+
"desired_capacity": scalingGroup.DesiredCapacity,
261+
"load_balancer_ids": helper.StringsInterfaces(scalingGroup.LoadBalancerIdSet),
262+
"termination_policies": helper.StringsInterfaces(scalingGroup.TerminationPolicySet),
263+
"retry_policy": scalingGroup.RetryPolicy,
264+
"create_time": scalingGroup.CreatedTime,
265+
"tags": tags,
266+
"multi_zone_subnet_policy": scalingGroup.MultiZoneSubnetPolicy,
261267
}
262268
if scalingGroup.ForwardLoadBalancerSet != nil && len(scalingGroup.ForwardLoadBalancerSet) > 0 {
263269
forwardLoadBalancers := make([]map[string]interface{}, 0, len(scalingGroup.ForwardLoadBalancerSet))

tencentcloud/data_source_tc_clb_instances.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ func dataSourceTencentCloudClbInstances() *schema.Resource {
5656
Optional: true,
5757
Description: "Used to save results.",
5858
},
59+
"master_zone": {
60+
Type: schema.TypeString,
61+
Optional: true,
62+
Description: "Master available zone id.",
63+
},
5964
"clb_list": {
6065
Type: schema.TypeList,
6166
Computed: true,
@@ -154,6 +159,31 @@ func dataSourceTencentCloudClbInstances() *schema.Resource {
154159
Computed: true,
155160
Description: "Max bandwidth out, only applicable to open CLB. Valid value ranges is [1, 2048]. Unit is MB.",
156161
},
162+
"zone_id": {
163+
Type: schema.TypeInt,
164+
Computed: true,
165+
Description: "Available zone unique id(numerical representation), This field maybe null, means cannot get a valid value.",
166+
},
167+
"zone": {
168+
Type: schema.TypeString,
169+
Computed: true,
170+
Description: "Available zone unique id(string representation), This field maybe null, means cannot get a valid value.",
171+
},
172+
"zone_name": {
173+
Type: schema.TypeString,
174+
Computed: true,
175+
Description: "Available zone name, This field maybe null, means cannot get a valid value.",
176+
},
177+
"zone_region": {
178+
Type: schema.TypeString,
179+
Computed: true,
180+
Description: "Region that this available zone belong to, This field maybe null, means cannot get a valid value.",
181+
},
182+
"local_zone": {
183+
Type: schema.TypeBool,
184+
Computed: true,
185+
Description: "Whether this available zone is local zone, This field maybe null, means cannot get a valid value.",
186+
},
157187
},
158188
},
159189
},
@@ -180,6 +210,9 @@ func dataSourceTencentCloudClbInstancesRead(d *schema.ResourceData, meta interfa
180210
if v, ok := d.GetOk("network_type"); ok {
181211
params["network_type"] = v.(string)
182212
}
213+
if v, ok := d.GetOk("master_zone"); ok {
214+
params["master_zone"] = v.(string)
215+
}
183216

184217
clbService := ClbService{
185218
client: meta.(*TencentCloudClient).apiV3Conn,
@@ -221,6 +254,14 @@ func dataSourceTencentCloudClbInstancesRead(d *schema.ResourceData, meta interfa
221254
mapping["internet_charge_type"] = *clbInstance.NetworkAttributes.InternetChargeType
222255
mapping["internet_bandwidth_max_out"] = *clbInstance.NetworkAttributes.InternetMaxBandwidthOut
223256
}
257+
if clbInstance.MasterZone != nil {
258+
mapping["zone_id"] = *clbInstance.MasterZone.ZoneId
259+
mapping["zone"] = *clbInstance.MasterZone.Zone
260+
mapping["zone_name"] = *clbInstance.MasterZone.ZoneName
261+
mapping["zone_region"] = *clbInstance.MasterZone.ZoneRegion
262+
mapping["local_zone"] = *clbInstance.MasterZone.LocalZone
263+
}
264+
224265
if clbInstance.Tags != nil {
225266
tags := make(map[string]interface{}, len(clbInstance.Tags))
226267
for _, t := range clbInstance.Tags {

tencentcloud/data_source_tc_kubernetes_clusters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func tkeClusterInfo() map[string]*schema.Schema {
137137
"is_non_static_ip_mode": {
138138
Type: schema.TypeBool,
139139
Computed: true,
140-
Description: "Indicates whether static ip mode is enabled.",
140+
Description: "Indicates whether non-static ip mode is enabled.",
141141
},
142142
"kube_proxy_mode": {
143143
Type: schema.TypeString,

tencentcloud/extension_as.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,8 @@ const (
147147
SCALING_GROUP_IN_ACTIVITY_STATUS = "IN_ACTIVITY"
148148
SCALING_GROUP_NOT_IN_ACTIVITY_STATUS = "NOT_IN_ACTIVITY"
149149
)
150+
151+
const (
152+
MultiZoneSubnetPolicyPriority = "PRIORITY"
153+
MultiZoneSubnetPolicyEquality = "EQUALITY"
154+
)

tencentcloud/resource_tc_as_scaling_group.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ func resourceTencentCloudAsScalingGroup() *schema.Resource {
216216
Computed: true,
217217
Description: "The time when the AS group was created.",
218218
},
219+
"multi_zone_subnet_policy": {
220+
Type: schema.TypeString,
221+
Optional: true,
222+
ValidateFunc: validateAllowedStringValue([]string{MultiZoneSubnetPolicyPriority,
223+
MultiZoneSubnetPolicyEquality}),
224+
Description: "Multi zone or subnet strategy, Valid values: PRIORITY and EQUALITY.",
225+
},
219226
},
220227
}
221228
}
@@ -303,6 +310,10 @@ func resourceTencentCloudAsScalingGroupCreate(d *schema.ResourceData, meta inter
303310
}
304311
}
305312

313+
if v, ok := d.GetOk("multi_zone_subnet_policy"); ok {
314+
request.MultiZoneSubnetPolicy = helper.String(v.(string))
315+
}
316+
306317
var id string
307318
if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
308319
ratelimit.Check(request.GetAction())
@@ -408,6 +419,7 @@ func resourceTencentCloudAsScalingGroupRead(d *schema.ResourceData, meta interfa
408419
_ = d.Set("termination_policies", helper.StringsInterfaces(scalingGroup.TerminationPolicySet))
409420
_ = d.Set("retry_policy", scalingGroup.RetryPolicy)
410421
_ = d.Set("create_time", scalingGroup.CreatedTime)
422+
_ = d.Set("multi_zone_subnet_policy", scalingGroup.MultiZoneSubnetPolicy)
411423

412424
if scalingGroup.ForwardLoadBalancerSet != nil && len(scalingGroup.ForwardLoadBalancerSet) > 0 {
413425
forwardLoadBalancers := make([]map[string]interface{}, 0, len(scalingGroup.ForwardLoadBalancerSet))
@@ -521,6 +533,11 @@ func resourceTencentCloudAsScalingGroupUpdate(d *schema.ResourceData, meta inter
521533
}
522534
}
523535

536+
if d.HasChange("multi_zone_subnet_policy") {
537+
updateAttrs = append(updateAttrs, "multi_zone_subnet_policy")
538+
request.MultiZoneSubnetPolicy = helper.String(d.Get("multi_zone_subnet_policy").(string))
539+
}
540+
524541
if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
525542
ratelimit.Check(request.GetAction())
526543

tencentcloud/resource_tc_clb_instance.go

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,60 @@ resource "tencentcloud_clb_instance" "open_clb" {
3737
}
3838
```
3939
40+
Default enable
41+
42+
```hcl
43+
resource "tencentcloud_subnet" "subnet" {
44+
availability_zone = "ap-guangzhou-1"
45+
name = "sdk-feature-test"
46+
vpc_id = tencentcloud_vpc.foo.id
47+
cidr_block = "10.0.20.0/28"
48+
is_multicast = false
49+
}
50+
51+
resource "tencentcloud_security_group" "sglab" {
52+
name = "sg_o0ek7r93"
53+
description = "favourite sg"
54+
project_id = 0
55+
}
56+
57+
resource "tencentcloud_vpc" "foo" {
58+
name = "for-my-open-clb"
59+
cidr_block = "10.0.0.0/16"
60+
61+
tags = {
62+
"test" = "mytest"
63+
}
64+
}
65+
66+
resource "tencentcloud_clb_instance" "open_clb" {
67+
network_type = "OPEN"
68+
clb_name = "my-open-clb"
69+
project_id = 0
70+
vpc_id = tencentcloud_vpc.foo.id
71+
load_balancer_pass_to_target = true
72+
73+
security_groups = [tencentcloud_security_group.sglab.id]
74+
target_region_info_region = "ap-guangzhou"
75+
target_region_info_vpc_id = tencentcloud_vpc.foo.id
76+
77+
tags = {
78+
test = "open"
79+
}
80+
}
81+
```
82+
83+
CREATE multiple instance
84+
85+
```hcl
86+
resource "tencentcloud_clb_instance" "open_clb1" {
87+
network_type = "OPEN"
88+
clb_name = "hello"
89+
master_zone_id = "ap-guangzhou-3"
90+
}
91+
~
92+
```
93+
4094
Import
4195
4296
CLB instance can be imported using the id, e.g.
@@ -178,7 +232,7 @@ func resourceTencentCloudClbInstance() *schema.Resource {
178232
"slave_zone_id": {
179233
Type: schema.TypeString,
180234
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",
235+
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.",
182236
},
183237
},
184238
}

0 commit comments

Comments
 (0)