Skip to content

Commit f7806f0

Browse files
committed
Add SQL Server Resources
2 parents e4bc48f + 2f8b97c commit f7806f0

File tree

56 files changed

+5443
-1635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5443
-1635
lines changed

CHANGELOG.md

Lines changed: 1093 additions & 1045 deletions
Large diffs are not rendered by default.
Lines changed: 99 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,99 @@
1-
data "tencentcloud_sqlserver_zone_configs" "foo" {
2-
}
3-
4-
resource "tencentcloud_vpc" "foo" {
5-
name = "example"
6-
cidr_block = "10.0.0.0/16"
7-
}
8-
9-
resource "tencentcloud_subnet" "foo" {
10-
name = "example"
11-
availability_zone = var.availability_zone
12-
vpc_id = tencentcloud_vpc.foo.id
13-
cidr_block = "10.0.0.0/24"
14-
is_multicast = false
15-
}
16-
17-
resource "tencentcloud_sqlserver_instance" "example" {
18-
name = "example"
19-
availability_zone = var.availability_zone
20-
charge_type = "POSTPAID_BY_HOUR"
21-
vpc_id = tencentcloud_vpc.foo.id
22-
subnet_id = tencentcloud_subnet.foo.id
23-
engine_version = "2008R2"
24-
project_id = 0
25-
memory = 2
26-
storage = 10
27-
}
28-
29-
resource "tencentcloud_sqlserver_db" "example" {
30-
instance_id = tencentcloud_sqlserver_instance.example.id
31-
name = "example"
32-
charset = "Chinese_PRC_BIN"
33-
remark = "tf"
34-
}
35-
36-
resource "tencentcloud_sqlserver_account" "example" {
37-
instance_id = tencentcloud_sqlserver_instance.example.id
38-
name = "example"
39-
password = "test1233"
40-
remark = "tf"
41-
}
42-
43-
resource "tencentcloud_sqlserver_account_db_attachment" "example" {
44-
instance_id = tencentcloud_sqlserver_instance.example.id
45-
account_name = tencentcloud_sqlserver_account.example.name
46-
db_name = tencentcloud_sqlserver_db.example.name
47-
privilege = "ReadWrite"
48-
}
49-
50-
data "tencentcloud_sqlserver_instances" "id_example" {
51-
id = tencentcloud_sqlserver_instance.example.id
52-
}
53-
54-
data "tencentcloud_sqlserver_instances" "vpc_example" {
55-
vpc_id = tencentcloud_vpc.foo.id
56-
subnet_id = tencentcloud_subnet.foo.id
57-
}
58-
59-
data "tencentcloud_sqlserver_instances" "project_example" {
60-
project_id = 0
61-
}
62-
63-
data "tencentcloud_sqlserver_dbs" "example" {
64-
instance_id = tencentcloud_sqlserver_db.example.instance_id
65-
}
66-
67-
data "tencentcloud_sqlserver_accounts" "example" {
68-
instance_id = tencentcloud_sqlserver_instance.example.id
69-
}
70-
71-
data "tencentcloud_sqlserver_account_db_attachments" "example" {
72-
instance_id = tencentcloud_sqlserver_instance.example.id
73-
account_name = tencentcloud_sqlserver_account.example.name
74-
}
75-
76-
data "tencentcloud_sqlserver_backups" "example" {
77-
instance_id = tencentcloud_sqlserver_instance.example.id
78-
start_time = "2020-06-30 00:00:00"
79-
end_time = "2020-07-01 00:00:00"
80-
}
1+
data "tencentcloud_sqlserver_zone_configs" "foo" {
2+
}
3+
4+
resource "tencentcloud_vpc" "foo" {
5+
name = "example"
6+
cidr_block = "10.0.0.0/16"
7+
}
8+
9+
resource "tencentcloud_subnet" "foo" {
10+
name = "example"
11+
availability_zone = var.availability_zone
12+
vpc_id = tencentcloud_vpc.foo.id
13+
cidr_block = "10.0.0.0/24"
14+
is_multicast = false
15+
}
16+
17+
resource "tencentcloud_sqlserver_instance" "example" {
18+
name = "example"
19+
availability_zone = var.availability_zone
20+
charge_type = "POSTPAID_BY_HOUR"
21+
vpc_id = tencentcloud_vpc.foo.id
22+
subnet_id = tencentcloud_subnet.foo.id
23+
engine_version = "2008R2"
24+
project_id = 0
25+
memory = 2
26+
storage = 10
27+
}
28+
29+
resource "tencentcloud_sqlserver_db" "example" {
30+
instance_id = tencentcloud_sqlserver_instance.example.id
31+
name = "example"
32+
charset = "Chinese_PRC_BIN"
33+
remark = "tf"
34+
}
35+
36+
resource "tencentcloud_sqlserver_account" "example" {
37+
instance_id = tencentcloud_sqlserver_instance.example.id
38+
name = "example"
39+
password = "test1233"
40+
remark = "tf"
41+
}
42+
43+
resource "tencentcloud_sqlserver_account_db_attachment" "example" {
44+
instance_id = tencentcloud_sqlserver_instance.example.id
45+
account_name = tencentcloud_sqlserver_account.example.name
46+
db_name = tencentcloud_sqlserver_db.example.name
47+
privilege = "ReadWrite"
48+
}
49+
50+
resource "tencentcloud_sqlserver_readonly_instance" "example" {
51+
name = "example"
52+
availability_zone = var.availability_zone
53+
charge_type = "POSTPAID_BY_HOUR"
54+
vpc_id = tencentcloud_vpc.foo.id
55+
subnet_id = tencentcloud_subnet.foo.id
56+
memory = 4
57+
storage = 20
58+
master_instance_id = tencentcloud_sqlserver_instance.test.id
59+
readonly_group_type = 1
60+
force_upgrade = true
61+
}
62+
63+
64+
data "tencentcloud_sqlserver_instances" "id_example" {
65+
id = tencentcloud_sqlserver_instance.example.id
66+
}
67+
68+
data "tencentcloud_sqlserver_instances" "vpc_example" {
69+
vpc_id = tencentcloud_vpc.foo.id
70+
subnet_id = tencentcloud_subnet.foo.id
71+
}
72+
73+
data "tencentcloud_sqlserver_instances" "project_example" {
74+
project_id = 0
75+
}
76+
77+
data "tencentcloud_sqlserver_dbs" "example" {
78+
instance_id = tencentcloud_sqlserver_db.example.instance_id
79+
}
80+
81+
data "tencentcloud_sqlserver_accounts" "example" {
82+
instance_id = tencentcloud_sqlserver_instance.example.id
83+
}
84+
85+
data "tencentcloud_sqlserver_account_db_attachments" "example" {
86+
instance_id = tencentcloud_sqlserver_instance.example.id
87+
account_name = tencentcloud_sqlserver_account.example.name
88+
}
89+
90+
data "tencentcloud_sqlserver_backups" "example" {
91+
instance_id = tencentcloud_sqlserver_instance.example.id
92+
start_time = "2020-06-30 00:00:00"
93+
end_time = "2020-07-01 00:00:00"
94+
}
95+
96+
data "tencentcloud_sqlserver_readonly_groups" "example"{
97+
master_instance_id = tencentcloud_sqlserver_instance.example.id
98+
}
99+

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/mattn/go-colorable v0.1.6 // indirect
1616
github.com/mitchellh/go-homedir v1.1.0
1717
github.com/pkg/errors v0.9.1
18-
github.com/tencentcloud/tencentcloud-sdk-go v3.0.196+incompatible
18+
github.com/tencentcloud/tencentcloud-sdk-go v3.0.221+incompatible
1919
github.com/yangwenmai/ratelimit v0.0.0-20180104140304-44221c2292e1
2020
github.com/zclconf/go-cty v1.4.2 // indirect
2121
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ github.com/hashicorp/terraform-json v0.4.0 h1:KNh29iNxozP5adfUFBJ4/fWd0Cu3taGgjH
250250
github.com/hashicorp/terraform-json v0.4.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8jnkVYN28gJkSJrLhU=
251251
github.com/hashicorp/terraform-plugin-sdk v1.7.0 h1:B//oq0ZORG+EkVrIJy0uPGSonvmXqxSzXe8+GhknoW0=
252252
github.com/hashicorp/terraform-plugin-sdk v1.7.0/go.mod h1:OjgQmey5VxnPej/buEhe+YqKm0KNvV3QqU4hkqHqPCY=
253-
github.com/hashicorp/terraform-plugin-sdk v1.13.1 h1:kWq+V+4BMFKtzIuO8wb/k4SRGB/VVF8g468VSFmAnKM=
254-
github.com/hashicorp/terraform-plugin-sdk v1.13.1/go.mod h1:HiWIPD/T9HixIhQUwaSoDQxo4BLFdmiBi/Qz5gjB8Q0=
255253
github.com/hashicorp/terraform-plugin-sdk v1.14.0 h1:sUKcw7OHqDXhBarlHjv+/yMCr8eEb1lO8CGQ3pEEFiE=
256254
github.com/hashicorp/terraform-plugin-sdk v1.14.0/go.mod h1:t62Xy+m7Zjq5tA2vrs8Wuo/TQ0sc9Mx9MjXL3+7MHBQ=
257255
github.com/hashicorp/terraform-plugin-test v1.2.0 h1:AWFdqyfnOj04sxTdaAF57QqvW7XXrT8PseUHkbKsE8I=
@@ -460,8 +458,8 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
460458
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
461459
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0KQWXKNqmwe8vEeSUiUj4Rlee9CMVX2ZUQ=
462460
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
463-
github.com/tencentcloud/tencentcloud-sdk-go v3.0.196+incompatible h1:aKWXYPLQ9NARP0tBESEtTfRLes88LaI+4qm3TSRDCjk=
464-
github.com/tencentcloud/tencentcloud-sdk-go v3.0.196+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
461+
github.com/tencentcloud/tencentcloud-sdk-go v3.0.221+incompatible h1:KfLv0pH+sYexx2FcvvPhek5kfiI14JB9JCTMkEWrNVE=
462+
github.com/tencentcloud/tencentcloud-sdk-go v3.0.221+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
465463
github.com/tetafro/godot v0.3.7 h1:+mecr7RKrUKB5UQ1gwqEMn13sDKTyDR8KNIquB9mm+8=
466464
github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
467465
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q=

tencentcloud/common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ func CheckNil(object interface{}, fields map[string]string) (nilFields []string)
191191
return
192192
}
193193

194+
// BuildTagResourceName builds the Tencent Cloud specific name of a resource description.
195+
// The format is `qcs:project_id:service_type:region:account:resource`.
196+
// For more information, go to https://cloud.tencent.com/document/product/598/10606.
194197
func BuildTagResourceName(serviceType, resourceType, region, id string) string {
195198
switch serviceType {
196199
case "cos":

tencentcloud/data_source_tc_mysql_instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
5050
"pay_type": {
5151
Type: schema.TypeInt,
5252
Optional: true,
53-
Deprecated: "It has been deprecated from version 1.36.0.",
53+
Deprecated: "It has been deprecated from version 1.36.0. Please use `charge_type` instead.",
5454
ValidateFunc: validateAllowedIntValue([]int{0, 1}),
5555
Description: "Pay type of instance, 0: prepay, 1: postpay.",
5656
},

tencentcloud/data_source_tc_sqlserver_instances.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ func dataSourceTencentCloudSqlserverInstances() *schema.Resource {
8484
Computed: true,
8585
Description: "Version of the SQL Server database engine. Allowed values are `2008R2`(SQL Server 2008 Enerprise), `2012SP3`(SQL Server 2012 Enterprise), `2016SP1` (SQL Server 2016 Enterprise), `201602`(SQL Server 2016 Standard) and `2017`(SQL Server 2017 Enterprise). Default is `2008R2`.",
8686
},
87+
"ha_type": {
88+
Type: schema.TypeString,
89+
Computed: true,
90+
Description: "Instance type.",
91+
},
8792
"vpc_id": {
8893
Type: schema.TypeString,
8994
Computed: true,
@@ -109,23 +114,27 @@ func dataSourceTencentCloudSqlserverInstances() *schema.Resource {
109114
Computed: true,
110115
Description: "Project ID, default value is 0.",
111116
},
117+
"ro_flag": {
118+
Type: schema.TypeString,
119+
Computed: true,
120+
Description: "Readonly flag. `RO` for readonly instance, `MASTER` for master instance, `` for not readonly instance.",
121+
},
112122
"availability_zone": {
113123
Type: schema.TypeString,
114124
Computed: true,
115125
Description: "Availability zone.",
116126
},
117-
//Computed values
118127
"used_storage": {
119128
Type: schema.TypeInt,
120129
Computed: true,
121130
Description: "Used storage.",
122131
},
123-
"private_access_ip": {
132+
"vip": {
124133
Type: schema.TypeString,
125134
Computed: true,
126135
Description: "IP for private access.",
127136
},
128-
"private_access_port": {
137+
"vport": {
129138
Type: schema.TypeInt,
130139
Computed: true,
131140
Description: "Port for private access.",
@@ -199,10 +208,11 @@ func dataSourceTencentCloudSqlserverInstanceRead(d *schema.ResourceData, meta in
199208
listItem["vpc_id"] = v.UniqVpcId
200209
listItem["subnet_id"] = v.UniqSubnetId
201210
listItem["engine_version"] = v.Version
202-
listItem["private_access_ip"] = v.Vip
203-
listItem["private_access_port"] = v.Vport
211+
listItem["vip"] = v.Vip
212+
listItem["vport"] = v.Vport
204213
listItem["used_storage"] = v.UsedStorage
205214
listItem["status"] = v.Status
215+
listItem["ro_flag"] = v.ROFlag
206216

207217
if *v.PayMode == 1 {
208218
listItem["charge_type"] = COMMON_PAYTYPE_PREPAID

tencentcloud/data_source_tc_sqlserver_instances_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func TestAccTencentCloudDataSqlserverInstances(t *testing.T) {
2727
resource.TestCheckResourceAttr(testDataSqlserverInstancesName, "instance_list.0.project_id", "0"),
2828
resource.TestCheckResourceAttr(testDataSqlserverInstancesName, "instance_list.0.memory", "2"),
2929
resource.TestCheckResourceAttr(testDataSqlserverInstancesName, "instance_list.0.storage", "10"),
30-
resource.TestCheckResourceAttrSet(testDataSqlserverInstancesName, "instance_list.0.private_access_ip"),
31-
resource.TestCheckResourceAttrSet(testDataSqlserverInstancesName, "instance_list.0.private_access_port"),
30+
resource.TestCheckResourceAttrSet(testDataSqlserverInstancesName, "instance_list.0.vip"),
31+
resource.TestCheckResourceAttrSet(testDataSqlserverInstancesName, "instance_list.0.vport"),
3232
resource.TestCheckResourceAttrSet(testDataSqlserverInstancesName, "instance_list.0.status"),
3333
resource.TestCheckResourceAttrSet(testDataSqlserverInstancesName, "instance_list.0.used_storage"),
3434
),

0 commit comments

Comments
 (0)