Skip to content

Commit 0c8f568

Browse files
authored
fix/sg-rule (#1992)
* fix/sg-rule * fix/sg-rule * fix/sg-rule
1 parent 8db01a6 commit 0c8f568

13 files changed

+396
-35
lines changed

tencentcloud/data_source_tc_sqlserver_account_db_attachments.go

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,69 @@ Use this data source to query the list of SQL Server account DB privileges.
44
Example Usage
55
66
```hcl
7-
data "tencentcloud_sqlserver_account_db_attachments" "test"{
8-
instance_id = tencentcloud_sqlserver_instance.test.id
9-
account_name = tencentcloud_sqlserver_account_db_attachment.test.account_name
7+
data "tencentcloud_availability_zones" "zones" {}
8+
9+
data "tencentcloud_sqlserver_account_db_attachments" "test" {
10+
instance_id = tencentcloud_sqlserver_instance.example.id
11+
account_name = tencentcloud_sqlserver_account_db_attachment.example.account_name
12+
}
13+
14+
resource "tencentcloud_vpc" "vpc" {
15+
name = "example-vpc"
16+
cidr_block = "10.0.0.0/16"
17+
}
18+
19+
resource "tencentcloud_subnet" "subnet" {
20+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
21+
name = "example-vpc"
22+
vpc_id = tencentcloud_vpc.vpc.id
23+
cidr_block = "10.0.0.0/16"
24+
is_multicast = false
25+
}
26+
27+
resource "tencentcloud_security_group" "security_group" {
28+
name = "example-sg"
29+
description = "desc."
30+
}
31+
32+
resource "tencentcloud_sqlserver_instance" "example" {
33+
name = "tf_example_sql"
34+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
35+
charge_type = "POSTPAID_BY_HOUR"
36+
period = 1
37+
vpc_id = tencentcloud_vpc.vpc.id
38+
subnet_id = tencentcloud_subnet.subnet.id
39+
security_groups = [tencentcloud_security_group.security_group.id]
40+
project_id = 0
41+
memory = 2
42+
storage = 20
43+
maintenance_week_set = [1, 2, 3]
44+
maintenance_start_time = "01:00"
45+
maintenance_time_span = 3
46+
tags = {
47+
"createBy" = "tfExample"
48+
}
49+
}
50+
51+
resource "tencentcloud_sqlserver_db" "example" {
52+
instance_id = tencentcloud_sqlserver_instance.example.id
53+
name = "tfExampleDb"
54+
charset = "Chinese_PRC_BIN"
55+
remark = "remark desc."
56+
}
57+
58+
resource "tencentcloud_sqlserver_account" "example" {
59+
instance_id = tencentcloud_sqlserver_instance.example.id
60+
name = "tf_example_account"
61+
password = "PassWord@123"
62+
remark = "remark desc."
63+
}
64+
65+
resource "tencentcloud_sqlserver_account_db_attachment" "example" {
66+
instance_id = tencentcloud_sqlserver_instance.example.id
67+
account_name = tencentcloud_sqlserver_account.example.name
68+
db_name = tencentcloud_sqlserver_db.example.name
69+
privilege = "ReadWrite"
1070
}
1171
```
1272
*/
@@ -84,15 +144,16 @@ func dataSourceTencentCloudSqlserverAccountDBAttachments() *schema.Resource {
84144
func dataSourceTencentSqlserverAccountDBAttachmentsRead(d *schema.ResourceData, meta interface{}) error {
85145
defer logElapsed("data_source.tencentcloud_sqlserver_account_db_attachments.read")()
86146

87-
logId := getLogId(contextNil)
88-
ctx := context.WithValue(context.TODO(), logIdKey, logId)
147+
var (
148+
logId = getLogId(contextNil)
149+
ctx = context.WithValue(context.TODO(), logIdKey, logId)
150+
sqlserverService = SqlserverService{client: meta.(*TencentCloudClient).apiV3Conn}
151+
)
89152

90153
instanceId := d.Get("instance_id").(string)
91154
accountName := d.Get("account_name").(string)
92155
dbName := d.Get("db_name").(string)
93156

94-
sqlserverService := SqlserverService{client: meta.(*TencentCloudClient).apiV3Conn}
95-
96157
attachments, err := sqlserverService.DescribeAccountDBAttachments(ctx, instanceId, accountName, dbName)
97158

98159
if err != nil {
@@ -119,6 +180,7 @@ func dataSourceTencentSqlserverAccountDBAttachmentsRead(d *schema.ResourceData,
119180
log.Printf("[CRITAL]%s provider set list fail, reason:%s\n", logId, e.Error())
120181
return e
121182
}
183+
122184
output, ok := d.GetOk("result_output_file")
123185
if ok && output.(string) != "" {
124186
return writeToFile(output.(string), list)

tencentcloud/data_source_tc_sqlserver_account_db_attachments_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import (
88

99
var testDataSqlserverAccountDBAttachmentsName = "data.tencentcloud_sqlserver_account_db_attachments.test"
1010

11-
func TestAccDataSourceTencentCloudSqlserverAccountDBAttachments(t *testing.T) {
11+
// go test -i; go test -test.run TestAccDataSourceTencentCloudSqlserverAccountDBAttachments_basic -v
12+
func TestAccDataSourceTencentCloudSqlserverAccountDBAttachments_basic(t *testing.T) {
1213
t.Parallel()
1314
resource.Test(t, resource.TestCase{
1415
PreCheck: func() { testAccPreCheck(t) },

tencentcloud/resource_tc_ckafka_acl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func resourceTencentCloudCkafkaAcl() *schema.Resource {
8282
Optional: true,
8383
Default: "*",
8484
ForceNew: true,
85-
Description: "IP address allowed to access. The default value is `*`, which means that any host can access.",
85+
Description: "The default is *, which means that any host can access it. Support filling in IP or network segment, and support `;`separation.",
8686
},
8787
"principal": {
8888
Type: schema.TypeString,

tencentcloud/resource_tc_sqlserver_complete_expansion.go

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,76 @@ Provides a resource to create a sqlserver complete_expansion
33
44
Example Usage
55
6+
First, Create a basic SQL instance
7+
8+
```hcl
9+
data "tencentcloud_availability_zones" "zones" {}
10+
11+
resource "tencentcloud_vpc" "vpc" {
12+
name = "example-vpc"
13+
cidr_block = "10.0.0.0/16"
14+
}
15+
16+
resource "tencentcloud_subnet" "subnet" {
17+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
18+
name = "example-vpc"
19+
vpc_id = tencentcloud_vpc.vpc.id
20+
cidr_block = "10.0.0.0/16"
21+
is_multicast = false
22+
}
23+
24+
resource "tencentcloud_security_group" "security_group" {
25+
name = "example-sg"
26+
description = "desc."
27+
}
28+
29+
resource "tencentcloud_sqlserver_instance" "example" {
30+
name = "tf_example_sql"
31+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
32+
charge_type = "POSTPAID_BY_HOUR"
33+
vpc_id = tencentcloud_vpc.vpc.id
34+
subnet_id = tencentcloud_subnet.subnet.id
35+
security_groups = [tencentcloud_security_group.security_group.id]
36+
project_id = 0
37+
memory = 2
38+
storage = 20
39+
maintenance_week_set = [1, 2, 3]
40+
maintenance_start_time = "01:00"
41+
maintenance_time_span = 3
42+
tags = {
43+
"createBy" = "tfExample"
44+
}
45+
}
46+
```
47+
48+
Expand the current instance, storage: 20->40, wait_switch = 1
49+
50+
```hcl
51+
resource "tencentcloud_sqlserver_instance" "example" {
52+
name = "tf_example_sql"
53+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
54+
charge_type = "POSTPAID_BY_HOUR"
55+
vpc_id = tencentcloud_vpc.vpc.id
56+
subnet_id = tencentcloud_subnet.subnet.id
57+
security_groups = [tencentcloud_security_group.security_group.id]
58+
project_id = 0
59+
memory = 2
60+
storage = 40
61+
wait_switch = 1
62+
maintenance_week_set = [1, 2, 3]
63+
maintenance_start_time = "01:00"
64+
maintenance_time_span = 3
65+
tags = {
66+
"createBy" = "tfExample"
67+
}
68+
}
69+
```
70+
71+
Complete the expansion task immediately
72+
673
```hcl
774
resource "tencentcloud_sqlserver_complete_expansion" "complete_expansion" {
8-
instance_id = "mssql-qelbzgwf"
75+
instance_id = tencentcloud_sqlserver_instance.example.id
976
}
1077
```
1178
*/

tencentcloud/resource_tc_sqlserver_complete_expansion_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
// go test -i; go test -test.run TestAccTencentCloudSqlserverCompleteExpansionResource_basic -v
10-
// go test -v -run TestAccTencentCloudSqlserverCompleteExpansionResource_basic -timeout=0 ./tencentcloud/
10+
// go test -v -run TestAccTencentCloudSqlserverCompleteExpansionResource_basic -timeout=0
1111
func TestAccTencentCloudSqlserverCompleteExpansionResource_basic(t *testing.T) {
1212
t.Parallel()
1313
resource.Test(t, resource.TestCase{

tencentcloud/resource_tc_sqlserver_database_tde.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@ Provides a resource to create a sqlserver database_tde
33
44
Example Usage
55
6+
Open database tde encryption
7+
68
```hcl
7-
resource "tencentcloud_sqlserver_database_tde" "database_tde" {
9+
resource "tencentcloud_sqlserver_database_tde" "example" {
810
instance_id = "mssql-qelbzgwf"
9-
db_names = ["keep_tde_db", "keep_tde_db2"]
11+
db_names = ["example_db1", "example_db2"]
1012
encryption = "enable"
1113
}
1214
```
1315
16+
Close database tde encryption
17+
18+
```hcl
19+
resource "tencentcloud_sqlserver_database_tde" "example" {
20+
instance_id = "mssql-qelbzgwf"
21+
db_names = ["example_db1", "example_db2"]
22+
encryption = "disable"
23+
}
24+
```
25+
1426
Import
1527
1628
sqlserver database_tde can be imported using the id, e.g.

tencentcloud/resource_tc_sqlserver_renew_db_instance.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,47 @@ Provides a resource to create a sqlserver renew_db_instance
44
Example Usage
55
66
```hcl
7+
data "tencentcloud_availability_zones" "zones" {}
8+
9+
resource "tencentcloud_vpc" "vpc" {
10+
name = "example-vpc"
11+
cidr_block = "10.0.0.0/16"
12+
}
13+
14+
resource "tencentcloud_subnet" "subnet" {
15+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
16+
name = "example-vpc"
17+
vpc_id = tencentcloud_vpc.vpc.id
18+
cidr_block = "10.0.0.0/16"
19+
is_multicast = false
20+
}
21+
22+
resource "tencentcloud_security_group" "security_group" {
23+
name = "example-sg"
24+
description = "desc."
25+
}
26+
27+
resource "tencentcloud_sqlserver_instance" "example" {
28+
name = "tf_example_sql"
29+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
30+
charge_type = "PREPAID"
31+
period = 1
32+
vpc_id = tencentcloud_vpc.vpc.id
33+
subnet_id = tencentcloud_subnet.subnet.id
34+
security_groups = [tencentcloud_security_group.security_group.id]
35+
project_id = 0
36+
memory = 2
37+
storage = 20
38+
maintenance_week_set = [1, 2, 3]
39+
maintenance_start_time = "01:00"
40+
maintenance_time_span = 3
41+
tags = {
42+
"createBy" = "tfExample"
43+
}
44+
}
45+
746
resource "tencentcloud_sqlserver_renew_db_instance" "renew_db_instance" {
8-
instance_id = "mssql-i1z41iwd"
47+
instance_id = tencentcloud_sqlserver_instance.example.id
948
period = 1
1049
}
1150
```

tencentcloud/resource_tc_sqlserver_renew_db_instance_test.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,26 @@ func TestAccTencentCloudSqlserverRenewDBInstanceResource_basic(t *testing.T) {
3030
}
3131

3232
const testAccSqlserverRenewDBInstance = testAccSqlserverInstanceBasicPrepaid + `
33+
data "tencentcloud_availability_zones" "zones" {}
34+
3335
resource "tencentcloud_sqlserver_instance" "test" {
34-
name = "test_sqlserver_instance"
35-
availability_zone = local.az
36-
charge_type = "PREPAID"
37-
period = 1
38-
vpc_id = local.vpc_id
39-
subnet_id = local.vpc_subnet_id
40-
project_id = 0
41-
memory = 2
42-
storage = 10
43-
maintenance_week_set = [1,2,3]
44-
maintenance_start_time = "09:00"
45-
maintenance_time_span = 3
46-
security_groups = [local.sg]
36+
name = "test_sqlserver_instance"
37+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
38+
charge_type = "PREPAID"
39+
period = 1
40+
vpc_id = local.vpc_id
41+
subnet_id = local.vpc_subnet_id
42+
project_id = 0
43+
memory = 2
44+
storage = 10
45+
maintenance_week_set = [1, 2, 3]
46+
maintenance_start_time = "09:00"
47+
maintenance_time_span = 3
48+
security_groups = [local.sg]
4749
}
4850
4951
resource "tencentcloud_sqlserver_renew_db_instance" "renew_db_instance" {
5052
instance_id = tencentcloud_sqlserver_instance.test.id
51-
period = 1
53+
period = 1
5254
}
5355
`

website/docs/d/sqlserver_account_db_attachments.html.markdown

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,69 @@ Use this data source to query the list of SQL Server account DB privileges.
1414
## Example Usage
1515

1616
```hcl
17+
data "tencentcloud_availability_zones" "zones" {}
18+
1719
data "tencentcloud_sqlserver_account_db_attachments" "test" {
18-
instance_id = tencentcloud_sqlserver_instance.test.id
19-
account_name = tencentcloud_sqlserver_account_db_attachment.test.account_name
20+
instance_id = tencentcloud_sqlserver_instance.example.id
21+
account_name = tencentcloud_sqlserver_account_db_attachment.example.account_name
22+
}
23+
24+
resource "tencentcloud_vpc" "vpc" {
25+
name = "example-vpc"
26+
cidr_block = "10.0.0.0/16"
27+
}
28+
29+
resource "tencentcloud_subnet" "subnet" {
30+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
31+
name = "example-vpc"
32+
vpc_id = tencentcloud_vpc.vpc.id
33+
cidr_block = "10.0.0.0/16"
34+
is_multicast = false
35+
}
36+
37+
resource "tencentcloud_security_group" "security_group" {
38+
name = "example-sg"
39+
description = "desc."
40+
}
41+
42+
resource "tencentcloud_sqlserver_instance" "example" {
43+
name = "tf_example_sql"
44+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
45+
charge_type = "POSTPAID_BY_HOUR"
46+
period = 1
47+
vpc_id = tencentcloud_vpc.vpc.id
48+
subnet_id = tencentcloud_subnet.subnet.id
49+
security_groups = [tencentcloud_security_group.security_group.id]
50+
project_id = 0
51+
memory = 2
52+
storage = 20
53+
maintenance_week_set = [1, 2, 3]
54+
maintenance_start_time = "01:00"
55+
maintenance_time_span = 3
56+
tags = {
57+
"createBy" = "tfExample"
58+
}
59+
}
60+
61+
resource "tencentcloud_sqlserver_db" "example" {
62+
instance_id = tencentcloud_sqlserver_instance.example.id
63+
name = "tfExampleDb"
64+
charset = "Chinese_PRC_BIN"
65+
remark = "remark desc."
66+
}
67+
68+
resource "tencentcloud_sqlserver_account" "example" {
69+
instance_id = tencentcloud_sqlserver_instance.example.id
70+
name = "tf_example_account"
71+
password = "PassWord@123"
72+
remark = "remark desc."
73+
}
74+
75+
resource "tencentcloud_sqlserver_account_db_attachment" "example" {
76+
instance_id = tencentcloud_sqlserver_instance.example.id
77+
account_name = tencentcloud_sqlserver_account.example.name
78+
db_name = tencentcloud_sqlserver_db.example.name
79+
privilege = "ReadWrite"
2080
}
2181
```
2282

0 commit comments

Comments
 (0)