Skip to content

Commit 6cba10e

Browse files
committed
add
1 parent eb2754b commit 6cba10e

6 files changed

+37
-137
lines changed

.changelog/2664.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

tencentcloud/services/clb/resource_tc_clb_instance.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ func ResourceTencentCloudClbInstance() *schema.Resource {
102102
"security_groups": {
103103
Type: schema.TypeList,
104104
Optional: true,
105-
Computed: true,
106105
Elem: &schema.Schema{Type: schema.TypeString},
107106
Description: "Security groups of the CLB instance. Supports both `OPEN` and `INTERNAL` CLBs.",
108107
},

tencentcloud/services/clb/resource_tc_clb_instance_test.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ resource "tencentcloud_clb_instance" "clb_internal" {
424424
`
425425

426426
const testAccClbInstance_open = `
427+
resource "tencentcloud_security_group" "foo" {
428+
name = "keep-ci-temp-test-sg"
429+
}
430+
427431
resource "tencentcloud_vpc" "foo" {
428432
name = "clb-instance-open-vpc"
429433
cidr_block = "10.0.0.0/16"
@@ -436,7 +440,7 @@ resource "tencentcloud_clb_instance" "clb_open" {
436440
vpc_id = tencentcloud_vpc.foo.id
437441
target_region_info_region = "ap-guangzhou"
438442
target_region_info_vpc_id = tencentcloud_vpc.foo.id
439-
security_groups = ["sg-5275dorp"]
443+
security_groups = [tencentcloud_security_group.foo.id]
440444
441445
tags = {
442446
test = "tf"
@@ -505,6 +509,10 @@ resource "tencentcloud_clb_instance" "clb_internal" {
505509
}
506510
`
507511
const testAccClbInstance_update_open = `
512+
resource "tencentcloud_security_group" "foo" {
513+
name = "clb-instance-sg"
514+
}
515+
508516
resource "tencentcloud_vpc" "foo" {
509517
name = "clb-instance-open-vpc"
510518
cidr_block = "10.0.0.0/16"
@@ -517,7 +525,7 @@ resource "tencentcloud_clb_instance" "clb_open" {
517525
project_id = 0
518526
target_region_info_region = "ap-guangzhou"
519527
target_region_info_vpc_id = tencentcloud_vpc.foo.id
520-
security_groups = ["sg-5275dorp"]
528+
security_groups = [tencentcloud_security_group.foo.id]
521529
522530
tags = {
523531
test = "test"
@@ -538,6 +546,12 @@ resource "tencentcloud_subnet" "subnet" {
538546
is_multicast = false
539547
}
540548
549+
resource "tencentcloud_security_group" "sglab" {
550+
name = "clb-instance-enable-sg"
551+
description = "favourite sg"
552+
project_id = 0
553+
}
554+
541555
resource "tencentcloud_vpc" "foo" {
542556
name = "clb-instance-default-vpc"
543557
cidr_block = "10.0.0.0/16"
@@ -554,7 +568,7 @@ resource "tencentcloud_clb_instance" "default_enable" {
554568
vpc_id = tencentcloud_vpc.foo.id
555569
load_balancer_pass_to_target = true
556570
557-
security_groups = ["sg-5275dorp"]
571+
security_groups = [tencentcloud_security_group.sglab.id]
558572
target_region_info_region = "ap-guangzhou"
559573
target_region_info_vpc_id = tencentcloud_vpc.foo.id
560574
@@ -577,6 +591,12 @@ resource "tencentcloud_subnet" "subnet" {
577591
is_multicast = false
578592
}
579593
594+
resource "tencentcloud_security_group" "sglab" {
595+
name = "clb-instance-enable-sg"
596+
description = "favourite sg"
597+
project_id = 0
598+
}
599+
580600
resource "tencentcloud_vpc" "foo" {
581601
name = "clb-instance-default-vpc"
582602
cidr_block = "10.0.0.0/16"
@@ -593,7 +613,7 @@ resource "tencentcloud_clb_instance" "default_enable" {
593613
vpc_id = tencentcloud_vpc.foo.id
594614
load_balancer_pass_to_target = true
595615
596-
security_groups = ["sg-5275dorp"]
616+
security_groups = [tencentcloud_security_group.sglab.id]
597617
target_region_info_region = "ap-guangzhou"
598618
target_region_info_vpc_id = tencentcloud_vpc.foo.id
599619

tencentcloud/services/clb/resource_tc_clb_security_group_attachment.md

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,9 @@ Provides a resource to create a clb security_group_attachment
33
Example Usage
44

55
```hcl
6-
# create security group
7-
resource "tencentcloud_security_group" "example" {
8-
name = "tf-example"
9-
description = "sg desc."
10-
project_id = 0
11-
12-
tags = {
13-
"example" = "test"
14-
}
15-
}
16-
17-
# create vpc
18-
resource "tencentcloud_vpc" "vpc" {
19-
name = "vpc"
20-
cidr_block = "10.0.0.0/16"
21-
}
22-
23-
# create vpc subnet
24-
resource "tencentcloud_subnet" "subnet" {
25-
name = "subnet"
26-
vpc_id = tencentcloud_vpc.vpc.id
27-
availability_zone = "ap-guangzhou-6"
28-
cidr_block = "10.0.20.0/28"
29-
is_multicast = false
30-
}
31-
32-
# create clb
33-
resource "tencentcloud_clb_instance" "example" {
34-
network_type = "INTERNAL"
35-
clb_name = "tf-example"
36-
project_id = 0
37-
vpc_id = tencentcloud_vpc.vpc.id
38-
subnet_id = tencentcloud_subnet.subnet.id
39-
40-
tags = {
41-
"example" = "test"
42-
}
43-
}
44-
45-
# attachment
46-
resource "tencentcloud_clb_security_group_attachment" "example" {
47-
security_group = tencentcloud_security_group.example.id
48-
load_balancer_ids = [tencentcloud_clb_instance.example.id]
6+
resource "tencentcloud_clb_security_group_attachment" "security_group_attachment" {
7+
security_group = "sg-ijato2x1"
8+
load_balancer_ids = ["lb-5dnrkgry"]
499
}
5010
```
5111

@@ -54,5 +14,5 @@ Import
5414
clb security_group_attachment can be imported using the id, e.g.
5515

5616
```
57-
terraform import tencentcloud_clb_security_group_attachment.example sg-5275dorp#lb-5dnrkgry
17+
terraform import tencentcloud_clb_security_group_attachment.security_group_attachment security_group_id#clb_id
5818
```

tencentcloud/services/clb/resource_tc_clb_security_group_attachment_test.go

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
99
)
1010

11-
// go test -i; go test -test.run TestAccTencentCloudClbSecurityGroupAttachmentResource_basic -v
1211
func TestAccTencentCloudClbSecurityGroupAttachmentResource_basic(t *testing.T) {
1312
t.Parallel()
1413
resource.Test(t, resource.TestCase{
@@ -19,14 +18,10 @@ func TestAccTencentCloudClbSecurityGroupAttachmentResource_basic(t *testing.T) {
1918
Steps: []resource.TestStep{
2019
{
2120
Config: testAccClbSecurityGroupAttachment,
22-
Check: resource.ComposeTestCheckFunc(
23-
resource.TestCheckResourceAttrSet("tencentcloud_clb_security_group_attachment.example", "id"),
24-
resource.TestCheckResourceAttrSet("tencentcloud_clb_security_group_attachment.example", "security_group"),
25-
resource.TestCheckResourceAttrSet("tencentcloud_clb_security_group_attachment.example", "load_balancer_ids.#"),
26-
),
21+
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_clb_security_group_attachment.security_group_attachment", "id")),
2722
},
2823
{
29-
ResourceName: "tencentcloud_clb_security_group_attachment.example",
24+
ResourceName: "tencentcloud_clb_security_group_attachment.security_group_attachment",
3025
ImportState: true,
3126
ImportStateVerify: true,
3227
},
@@ -35,37 +30,10 @@ func TestAccTencentCloudClbSecurityGroupAttachmentResource_basic(t *testing.T) {
3530
}
3631

3732
const testAccClbSecurityGroupAttachment = `
38-
# create vpc
39-
resource "tencentcloud_vpc" "vpc" {
40-
name = "vpc"
41-
cidr_block = "10.0.0.0/16"
42-
}
4333
44-
# create vpc subnet
45-
resource "tencentcloud_subnet" "subnet" {
46-
name = "subnet"
47-
vpc_id = tencentcloud_vpc.vpc.id
48-
availability_zone = "ap-guangzhou-6"
49-
cidr_block = "10.0.20.0/28"
50-
is_multicast = false
34+
resource "tencentcloud_clb_security_group_attachment" "security_group_attachment" {
35+
security_group = "sg-ijato2x1"
36+
load_balancer_ids = ["lb-5dnrkgry"]
5137
}
5238
53-
# create clb
54-
resource "tencentcloud_clb_instance" "example" {
55-
network_type = "INTERNAL"
56-
clb_name = "tf-example"
57-
project_id = 0
58-
vpc_id = tencentcloud_vpc.vpc.id
59-
subnet_id = tencentcloud_subnet.subnet.id
60-
61-
tags = {
62-
"example" = "test"
63-
}
64-
}
65-
66-
# attachment
67-
resource "tencentcloud_clb_security_group_attachment" "example" {
68-
security_group = "sg-5275dorp"
69-
load_balancer_ids = [tencentcloud_clb_instance.example.id]
70-
}
7139
`

website/docs/r/clb_security_group_attachment.html.markdown

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,9 @@ Provides a resource to create a clb security_group_attachment
1414
## Example Usage
1515

1616
```hcl
17-
# create security group
18-
resource "tencentcloud_security_group" "example" {
19-
name = "tf-example"
20-
description = "sg desc."
21-
project_id = 0
22-
23-
tags = {
24-
"example" = "test"
25-
}
26-
}
27-
28-
# create vpc
29-
resource "tencentcloud_vpc" "vpc" {
30-
name = "vpc"
31-
cidr_block = "10.0.0.0/16"
32-
}
33-
34-
# create vpc subnet
35-
resource "tencentcloud_subnet" "subnet" {
36-
name = "subnet"
37-
vpc_id = tencentcloud_vpc.vpc.id
38-
availability_zone = "ap-guangzhou-6"
39-
cidr_block = "10.0.20.0/28"
40-
is_multicast = false
41-
}
42-
43-
# create clb
44-
resource "tencentcloud_clb_instance" "example" {
45-
network_type = "INTERNAL"
46-
clb_name = "tf-example"
47-
project_id = 0
48-
vpc_id = tencentcloud_vpc.vpc.id
49-
subnet_id = tencentcloud_subnet.subnet.id
50-
51-
tags = {
52-
"example" = "test"
53-
}
54-
}
55-
56-
# attachment
57-
resource "tencentcloud_clb_security_group_attachment" "example" {
58-
security_group = tencentcloud_security_group.example.id
59-
load_balancer_ids = [tencentcloud_clb_instance.example.id]
17+
resource "tencentcloud_clb_security_group_attachment" "security_group_attachment" {
18+
security_group = "sg-ijato2x1"
19+
load_balancer_ids = ["lb-5dnrkgry"]
6020
}
6121
```
6222

@@ -80,6 +40,6 @@ In addition to all arguments above, the following attributes are exported:
8040
clb security_group_attachment can be imported using the id, e.g.
8141

8242
```
83-
terraform import tencentcloud_clb_security_group_attachment.example sg-5275dorp#lb-5dnrkgry
43+
terraform import tencentcloud_clb_security_group_attachment.security_group_attachment security_group_id#clb_id
8444
```
8545

0 commit comments

Comments
 (0)