Skip to content

Commit d5a27f8

Browse files
authored
Merge pull request #701 from tencentcloudstack/fix/vpc-sec-group
fix: vpc - lite rule support multiple resource, skip empty import set
2 parents bc1ba35 + 61fe9ec commit d5a27f8

11 files changed

+239
-107
lines changed

tencentcloud/resource_tc_address_template_group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Example Usage
66
```hcl
77
resource "tencentcloud_address_template_group" "foo" {
88
name = "group-test"
9-
addresses = ["ipl-axaf24151","ipl-axaf24152"]
9+
template_ids = ["ipl-axaf24151","ipl-axaf24152"]
1010
}
1111
```
1212

tencentcloud/resource_tc_clb_listener.go

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,17 @@ func resourceTencentCloudClbListenerRead(d *schema.ResourceData, meta interface{
526526

527527
_ = d.Set("clb_id", clbId)
528528
_ = d.Set("listener_id", instance.ListenerId)
529-
_ = d.Set("listener_name", instance.ListenerName)
530-
_ = d.Set("target_type", instance.TargetType)
531529
_ = d.Set("port", instance.Port)
532530
_ = d.Set("protocol", instance.Protocol)
533-
_ = d.Set("session_expire_time", instance.SessionExpireTime)
531+
if instance.ListenerName != nil {
532+
_ = d.Set("listener_name", instance.ListenerName)
533+
}
534+
if instance.TargetType != nil {
535+
_ = d.Set("target_type", instance.TargetType)
536+
}
537+
if instance.SessionExpireTime != nil {
538+
_ = d.Set("session_expire_time", instance.SessionExpireTime)
539+
}
534540
if *instance.Protocol == CLB_LISTENER_PROTOCOL_TCP || *instance.Protocol == CLB_LISTENER_PROTOCOL_TCPSSL || *instance.Protocol == CLB_LISTENER_PROTOCOL_UDP {
535541
_ = d.Set("scheduler", instance.Scheduler)
536542
}
@@ -543,20 +549,48 @@ func resourceTencentCloudClbListenerRead(d *schema.ResourceData, meta interface{
543549
healthCheckSwitch = true
544550
}
545551
_ = d.Set("health_check_switch", healthCheckSwitch)
546-
_ = d.Set("health_check_interval_time", instance.HealthCheck.IntervalTime)
547-
_ = d.Set("health_check_time_out", instance.HealthCheck.TimeOut)
548-
_ = d.Set("health_check_health_num", instance.HealthCheck.HealthNum)
549-
_ = d.Set("health_check_unhealth_num", instance.HealthCheck.UnHealthNum)
550-
_ = d.Set("health_check_port", instance.HealthCheck.CheckPort)
551-
_ = d.Set("health_check_type", instance.HealthCheck.CheckType)
552-
_ = d.Set("health_check_http_code", instance.HealthCheck.HttpCode)
553-
_ = d.Set("health_check_http_path", instance.HealthCheck.HttpCheckPath)
554-
_ = d.Set("health_check_http_domain", instance.HealthCheck.HttpCheckDomain)
555-
_ = d.Set("health_check_http_method", instance.HealthCheck.HttpCheckMethod)
556-
_ = d.Set("health_check_http_version", instance.HealthCheck.HttpVersion)
557-
_ = d.Set("health_check_context_type", instance.HealthCheck.ContextType)
558-
_ = d.Set("health_check_send_context", instance.HealthCheck.SendContext)
559-
_ = d.Set("health_check_recv_context", instance.HealthCheck.RecvContext)
552+
if instance.HealthCheck.IntervalTime != nil {
553+
_ = d.Set("health_check_interval_time", instance.HealthCheck.IntervalTime)
554+
}
555+
if instance.HealthCheck.TimeOut != nil {
556+
_ = d.Set("health_check_time_out", instance.HealthCheck.TimeOut)
557+
}
558+
if instance.HealthCheck.HealthNum != nil {
559+
_ = d.Set("health_check_health_num", instance.HealthCheck.HealthNum)
560+
}
561+
if instance.HealthCheck.UnHealthNum != nil {
562+
_ = d.Set("health_check_unhealth_num", instance.HealthCheck.UnHealthNum)
563+
}
564+
if instance.HealthCheck.CheckPort != nil {
565+
_ = d.Set("health_check_port", instance.HealthCheck.CheckPort)
566+
}
567+
if instance.HealthCheck.CheckType != nil {
568+
_ = d.Set("health_check_type", instance.HealthCheck.CheckType)
569+
}
570+
if instance.HealthCheck.HttpCode != nil {
571+
_ = d.Set("health_check_http_code", instance.HealthCheck.HttpCode)
572+
}
573+
if instance.HealthCheck.HttpCheckPath != nil {
574+
_ = d.Set("health_check_http_path", instance.HealthCheck.HttpCheckPath)
575+
}
576+
if instance.HealthCheck.HttpCheckDomain != nil {
577+
_ = d.Set("health_check_http_domain", instance.HealthCheck.HttpCheckDomain)
578+
}
579+
if instance.HealthCheck.HttpCheckMethod != nil {
580+
_ = d.Set("health_check_http_method", instance.HealthCheck.HttpCheckMethod)
581+
}
582+
if instance.HealthCheck.HttpVersion != nil {
583+
_ = d.Set("health_check_http_version", instance.HealthCheck.HttpVersion)
584+
}
585+
if instance.HealthCheck.ContextType != nil {
586+
_ = d.Set("health_check_context_type", instance.HealthCheck.ContextType)
587+
}
588+
if instance.HealthCheck.SendContext != nil {
589+
_ = d.Set("health_check_send_context", instance.HealthCheck.SendContext)
590+
}
591+
if instance.HealthCheck.RecvContext != nil {
592+
_ = d.Set("health_check_recv_context", instance.HealthCheck.RecvContext)
593+
}
560594
}
561595

562596
if instance.Certificate != nil {

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,14 +2025,13 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
20252025
name := dMap["name"].(string)
20262026
param := dMap["param"].(string)
20272027
addon := &tke.ExtensionAddon{
2028-
AddonName: helper.String(name),
2028+
AddonName: helper.String(name),
20292029
AddonParam: helper.String(param),
20302030
}
20312031
extensionAddons = append(extensionAddons, addon)
20322032
}
20332033
}
20342034

2035-
20362035
service := TkeService{client: meta.(*TencentCloudClient).apiV3Conn}
20372036
id, err := service.CreateCluster(ctx, basic, advanced, cvms, iAdvanced, cidrSet, tags, existInstances, &overrideSettings, iDiskMountSettings, extensionAddons)
20382037
if err != nil {

tencentcloud/resource_tc_security_group_lite_rule.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ resource "tencentcloud_security_group_lite_rule" "foo" {
1717
"ACCEPT#192.168.1.0/24#80#TCP",
1818
"DROP#8.8.8.8#80,90#UDP",
1919
"ACCEPT#0.0.0.0/0#80-90#TCP",
20+
"ACCEPT#sg-7ixn3foj/0#80-90#TCP",
21+
"ACCEPT#ipm-epjq5kn0/0#80-90#TCP",
22+
"ACCEPT#ipmg-3loavam6/0#80-90#TCP",
2023
]
2124
2225
egress = [
@@ -65,13 +68,13 @@ func resourceTencentCloudSecurityGroupLiteRule() *schema.Resource {
6568
Type: schema.TypeList,
6669
Optional: true,
6770
Elem: &schema.Schema{Type: schema.TypeString},
68-
Description: "Ingress rules set. A rule must match the following format: [action]#[cidr_ip]#[port]#[protocol]. The available value of 'action' is `ACCEPT` and `DROP`. The 'cidr_ip' must be an IP address network or segment. The 'port' valid format is `80`, `80,443`, `80-90` or `ALL`. The available value of 'protocol' is `TCP`, `UDP`, `ICMP` and `ALL`. When 'protocol' is `ICMP` or `ALL`, the 'port' must be `ALL`.",
71+
Description: "Ingress rules set. A rule must match the following format: [action]#[source]#[port]#[protocol]. The available value of 'action' is `ACCEPT` and `DROP`. The 'source' can be an IP address network, segment, security group ID and Address Template ID. The 'port' valid format is `80`, `80,443`, `80-90` or `ALL`. The available value of 'protocol' is `TCP`, `UDP`, `ICMP` and `ALL`. When 'protocol' is `ICMP` or `ALL`, the 'port' must be `ALL`.",
6972
},
7073
"egress": {
7174
Type: schema.TypeList,
7275
Optional: true,
7376
Elem: &schema.Schema{Type: schema.TypeString},
74-
Description: "Egress rules set. A rule must match the following format: [action]#[cidr_ip]#[port]#[protocol]. The available value of 'action' is `ACCEPT` and `DROP`. The 'cidr_ip' must be an IP address network or segment. The 'port' valid format is `80`, `80,443`, `80-90` or `ALL`. The available value of 'protocol' is `TCP`, `UDP`, `ICMP` and `ALL`. When 'protocol' is `ICMP` or `ALL`, the 'port' must be `ALL`.",
77+
Description: "Egress rules set. A rule must match the following format: [action]#[source]#[port]#[protocol]. The available value of 'action' is `ACCEPT` and `DROP`. The 'source' can be an IP address network, segment, security group ID and Address Template ID. The 'port' valid format is `80`, `80,443`, `80-90` or `ALL`. The available value of 'protocol' is `TCP`, `UDP`, `ICMP` and `ALL`. When 'protocol' is `ICMP` or `ALL`, the 'port' must be `ALL`.",
7578
},
7679
},
7780
}

tencentcloud/resource_tc_security_group_lite_rule_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ func TestAccTencentCloudSecurityGroupLiteRule_update(t *testing.T) {
124124
resource.TestCheckResourceAttr("tencentcloud_security_group_lite_rule.foo", "egress.#", "0"),
125125
),
126126
},
127+
{
128+
Config: testAccSecurityGroupLiteRuleUpdate6,
129+
Check: resource.ComposeTestCheckFunc(
130+
testAccCheckSecurityGroupLiteRuleExists("tencentcloud_security_group_lite_rule.foo", &liteRuleId),
131+
resource.TestCheckResourceAttrSet("tencentcloud_security_group_lite_rule.foo", "security_group_id"),
132+
resource.TestCheckResourceAttr("tencentcloud_security_group_lite_rule.foo", "ingress.#", "5"),
133+
resource.TestCheckResourceAttrSet("tencentcloud_security_group_lite_rule.foo", "ingress.0"),
134+
resource.TestCheckResourceAttrSet("tencentcloud_security_group_lite_rule.foo", "ingress.1"),
135+
resource.TestCheckResourceAttr("tencentcloud_security_group_lite_rule.foo", "ingress.2", "ACCEPT#0.0.0.0/0#80-90#TCP"),
136+
resource.TestCheckResourceAttr("tencentcloud_security_group_lite_rule.foo", "ingress.3", "DROP#8.8.8.8#80,90#UDP"),
137+
resource.TestCheckResourceAttrSet("tencentcloud_security_group_lite_rule.foo", "ingress.4"),
138+
resource.TestCheckResourceAttr("tencentcloud_security_group_lite_rule.foo", "egress.#", "2"),
139+
resource.TestCheckResourceAttr("tencentcloud_security_group_lite_rule.foo", "egress.0", "ACCEPT#192.168.0.0/16#ALL#TCP"),
140+
resource.TestCheckResourceAttrSet("tencentcloud_security_group_lite_rule.foo", "egress.1"),
141+
),
142+
},
127143
},
128144
})
129145
}
@@ -274,3 +290,42 @@ resource "tencentcloud_security_group_lite_rule" "foo" {
274290
security_group_id = tencentcloud_security_group.foo.id
275291
}
276292
`
293+
const testAccSecurityGroupLiteRuleUpdate6 = `
294+
resource "tencentcloud_security_group" "foo" {
295+
name = "ci-temp-test-sg"
296+
}
297+
298+
resource "tencentcloud_security_group" "group1" {
299+
name = "tf-test-sec"
300+
}
301+
302+
resource "tencentcloud_address_template" "addr-foo" {
303+
name = "tf-test-addr"
304+
addresses = ["10.0.0.1", "10.0.1.0/24", "10.0.0.1-10.0.0.100"]
305+
}
306+
307+
resource "tencentcloud_address_template" "addr-bar" {
308+
name = "cam-user-test"
309+
addresses = ["10.0.2.1", "10.0.3.0/24"]
310+
}
311+
312+
resource "tencentcloud_address_template_group" "foo" {
313+
name = "group-test"
314+
template_ids = [tencentcloud_address_template.addr-foo.id, tencentcloud_address_template.addr-bar.id]
315+
}
316+
317+
resource "tencentcloud_security_group_lite_rule" "foo" {
318+
security_group_id = tencentcloud_security_group.foo.id
319+
ingress = [
320+
"ACCEPT#${tencentcloud_address_template_group.foo.id}#8080#TCP",
321+
"DROP#${tencentcloud_address_template.addr-foo.id}#8080#TCP",
322+
"ACCEPT#0.0.0.0/0#80-90#TCP",
323+
"DROP#8.8.8.8#80,90#UDP",
324+
"ACCEPT#${tencentcloud_security_group.group1.id}#80#TCP",
325+
]
326+
egress = [
327+
"ACCEPT#192.168.0.0/16#ALL#TCP",
328+
"ACCEPT#${tencentcloud_security_group.group1.id}#ALL#TCP",
329+
]
330+
}
331+
`

tencentcloud/resource_tc_tdmq_namespace_role_attachment.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func resourceTencentCloudTdmqNamespaceRoleAttachmentUpdate(d *schema.ResourceDat
199199
service := TdmqService{client: meta.(*TencentCloudClient).apiV3Conn}
200200

201201
var (
202-
permissions [] *string
202+
permissions []*string
203203
)
204204
old, now := d.GetChange("permissions")
205205
if d.HasChange("permissions") {
@@ -237,7 +237,6 @@ func resourceTencentCloudTdmqNamespaceRoleAttachmentDelete(d *schema.ResourceDat
237237
roleName := idSplit[1]
238238
clusterId := d.Get("cluster_id").(string)
239239

240-
241240
service := TdmqService{client: meta.(*TencentCloudClient).apiV3Conn}
242241

243242
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {

tencentcloud/resource_tc_tdmq_role.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ func resourceTencentCloudTdmqRoleCreate(d *schema.ResourceData, meta interface{}
8989
tdmqService := TdmqService{client: meta.(*TencentCloudClient).apiV3Conn}
9090

9191
var (
92-
roleName string
93-
clusterId string
94-
remark string
92+
roleName string
93+
clusterId string
94+
remark string
9595
)
9696
if temp, ok := d.GetOk("role_name"); ok {
9797
roleName = temp.(string)
@@ -164,7 +164,7 @@ func resourceTencentCloudTdmqRoleUpdate(d *schema.ResourceData, meta interface{}
164164
service := TdmqService{client: meta.(*TencentCloudClient).apiV3Conn}
165165

166166
var (
167-
remark string
167+
remark string
168168
)
169169
old, now := d.GetChange("remark")
170170
if d.HasChange("remark") {

tencentcloud/service_tencentcloud_tdmq.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func (me *TdmqService) DeleteTdmqTopic(ctx context.Context, environId string, to
384384
}
385385
}()
386386
var (
387-
topicRecord tdmq.TopicRecord
387+
topicRecord tdmq.TopicRecord
388388
)
389389
topicRecord.TopicName = &topicName
390390
topicRecord.EnvironmentId = &environId
@@ -655,4 +655,4 @@ func (me *TdmqService) DeleteTdmqNamespaceRoleAttachment(ctx context.Context, en
655655
return err
656656
}
657657
return
658-
}
658+
}

0 commit comments

Comments
 (0)