Skip to content

Commit 8292fa6

Browse files
committed
add
1 parent 85ad952 commit 8292fa6

File tree

2 files changed

+80
-54
lines changed

2 files changed

+80
-54
lines changed

tencentcloud/services/postgresql/resource_tc_postgresql_instance.md

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
Use this resource to create postgresql instance.
22

33
-> **Note:** To update the charge type, please update the `charge_type` and specify the `period` for the charging period. It only supports updating from `POSTPAID_BY_HOUR` to `PREPAID`, and the `period` field only valid in that upgrading case.
4+
-> **Note:** If no values are set for the two parameters: `db_major_version` and `engine_version`, then `engine_version` is set to `10.4` by default. Suggest using parameter `db_major_version` to create an instance
45

56
Example Usage
67

78
```hcl
89
variable "availability_zone" {
9-
default = "ap-guangzhou-1"
10+
default = "ap-guangzhou-3"
1011
}
1112
1213
# create vpc
1314
resource "tencentcloud_vpc" "vpc" {
14-
name = "guagua_vpc_instance_test"
15+
name = "vpc"
1516
cidr_block = "10.0.0.0/16"
1617
}
1718
1819
# create vpc subnet
1920
resource "tencentcloud_subnet" "subnet" {
2021
availability_zone = var.availability_zone
21-
name = "guagua_vpc_subnet_test"
22+
name = "subnet"
2223
vpc_id = tencentcloud_vpc.vpc.id
2324
cidr_block = "10.0.20.0/28"
2425
is_multicast = false
2526
}
2627
2728
# create postgresql
28-
resource "tencentcloud_postgresql_instance" "foo" {
29+
resource "tencentcloud_postgresql_instance" "example" {
2930
name = "example"
3031
availability_zone = var.availability_zone
3132
charge_type = "POSTPAID_BY_HOUR"
3233
vpc_id = tencentcloud_vpc.vpc.id
3334
subnet_id = tencentcloud_subnet.subnet.id
34-
engine_version = "10.4"
35+
db_major_version = "10"
36+
engine_version = "10.23"
3537
root_user = "root123"
3638
root_password = "Root123$"
3739
charset = "UTF8"
3840
project_id = 0
41+
cpu = 1
3942
memory = 2
4043
storage = 10
4144
@@ -58,21 +61,21 @@ variable "standby_availability_zone" {
5861
5962
# create vpc
6063
resource "tencentcloud_vpc" "vpc" {
61-
name = "guagua_vpc_instance_test"
64+
name = "vpc"
6265
cidr_block = "10.0.0.0/16"
6366
}
6467
6568
# create vpc subnet
6669
resource "tencentcloud_subnet" "subnet" {
6770
availability_zone = var.availability_zone
68-
name = "guagua_vpc_subnet_test"
71+
name = "subnet"
6972
vpc_id = tencentcloud_vpc.vpc.id
7073
cidr_block = "10.0.20.0/28"
7174
is_multicast = false
7275
}
7376
7477
# create postgresql
75-
resource "tencentcloud_postgresql_instance" "foo" {
78+
resource "tencentcloud_postgresql_instance" "example" {
7679
name = "example"
7780
availability_zone = var.availability_zone
7881
charge_type = "POSTPAID_BY_HOUR"
@@ -91,6 +94,7 @@ resource "tencentcloud_postgresql_instance" "foo" {
9194
role = "Primary"
9295
zone = var.availability_zone
9396
}
97+
9498
db_node_set {
9599
zone = var.standby_availability_zone
96100
}
@@ -102,20 +106,24 @@ resource "tencentcloud_postgresql_instance" "foo" {
102106
```
103107

104108
create pgsql with kms key
105-
```
106-
resource "tencentcloud_postgresql_instance" "pg" {
109+
```hcl
110+
variable "availability_zone" {
111+
default = "ap-guangzhou-6"
112+
}
113+
114+
resource "tencentcloud_postgresql_instance" "example" {
107115
name = "tf_postsql_instance"
108-
availability_zone = "ap-guangzhou-6"
116+
availability_zone = var.availability_zone
109117
charge_type = "POSTPAID_BY_HOUR"
110118
vpc_id = "vpc-86v957zb"
111119
subnet_id = "subnet-enm92y0m"
120+
db_major_version = "11"
112121
engine_version = "11.12"
113-
# db_major_vesion = "11"
114122
db_kernel_version = "v11.12_r1.3"
115123
need_support_tde = 1
116124
kms_key_id = "788c606a-c7b7-11ec-82d1-5254001e5c4e"
117125
kms_region = "ap-guangzhou"
118-
root_password = "xxxxxxxxxx"
126+
root_password = "Root123$"
119127
charset = "LATIN1"
120128
project_id = 0
121129
memory = 4
@@ -135,32 +143,37 @@ resource "tencentcloud_postgresql_instance" "pg" {
135143
```
136144

137145
upgrade kernel version
138-
```
139-
resource "tencentcloud_postgresql_instance" "test" {
140-
name = "tf_postsql_instance_update"
141-
availability_zone = data.tencentcloud_availability_zones_by_product.zone.zones[5].name
142-
charge_type = "POSTPAID_BY_HOUR"
143-
vpc_id = local.vpc_id
144-
subnet_id = local.subnet_id
145-
engine_version = "13.3"
146-
root_password = "*"
147-
charset = "LATIN1"
148-
project_id = 0
146+
```hcl
147+
variable "availability_zone" {
148+
default = "ap-guangzhou-6"
149+
}
150+
151+
resource "tencentcloud_postgresql_instance" "example" {
152+
name = "tf_postsql_instance_update_kernel"
153+
availability_zone = var.availability_zone
154+
charge_type = "POSTPAID_BY_HOUR"
155+
vpc_id = "vpc-86v957zb"
156+
subnet_id = "subnet-enm92y0m"
157+
engine_version = "13.3"
158+
root_password = "Root123$"
159+
charset = "LATIN1"
160+
project_id = 0
149161
public_access_switch = false
150-
security_groups = [local.sg_id]
151-
memory = 4
152-
storage = 250
162+
security_groups = ["sg-cm7fbbf3"]
163+
memory = 4
164+
storage = 250
165+
153166
backup_plan {
154-
min_backup_start_time = "01:10:11"
155-
max_backup_start_time = "02:10:11"
156-
base_backup_retention_period = 5
157-
backup_period = ["monday", "thursday", "sunday"]
167+
min_backup_start_time = "01:10:11"
168+
max_backup_start_time = "02:10:11"
169+
base_backup_retention_period = 5
170+
backup_period = ["monday", "thursday", "sunday"]
158171
}
159172
160173
db_kernel_version = "v13.3_r1.4" # eg:from v13.3_r1.1 to v13.3_r1.4
161174
162175
tags = {
163-
tf = "teest"
176+
tf = "test"
164177
}
165178
}
166179
```
@@ -170,5 +183,5 @@ Import
170183
postgresql instance can be imported using the id, e.g.
171184

172185
```
173-
$ terraform import tencentcloud_postgresql_instance.foo postgres-cda1iex1
186+
$ terraform import tencentcloud_postgresql_instance.example postgres-cda1iex1
174187
```

website/docs/r/postgresql_instance.html.markdown

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,44 @@ description: |-
1212
Use this resource to create postgresql instance.
1313

1414
-> **Note:** To update the charge type, please update the `charge_type` and specify the `period` for the charging period. It only supports updating from `POSTPAID_BY_HOUR` to `PREPAID`, and the `period` field only valid in that upgrading case.
15+
-> **Note:** If no values are set for the two parameters: `db_major_version` and `engine_version`, then `engine_version` is set to `10.4` by default. Suggest using parameter `db_major_version` to create an instance
1516

1617
## Example Usage
1718

1819
```hcl
1920
variable "availability_zone" {
20-
default = "ap-guangzhou-1"
21+
default = "ap-guangzhou-3"
2122
}
2223
2324
# create vpc
2425
resource "tencentcloud_vpc" "vpc" {
25-
name = "guagua_vpc_instance_test"
26+
name = "vpc"
2627
cidr_block = "10.0.0.0/16"
2728
}
2829
2930
# create vpc subnet
3031
resource "tencentcloud_subnet" "subnet" {
3132
availability_zone = var.availability_zone
32-
name = "guagua_vpc_subnet_test"
33+
name = "subnet"
3334
vpc_id = tencentcloud_vpc.vpc.id
3435
cidr_block = "10.0.20.0/28"
3536
is_multicast = false
3637
}
3738
3839
# create postgresql
39-
resource "tencentcloud_postgresql_instance" "foo" {
40+
resource "tencentcloud_postgresql_instance" "example" {
4041
name = "example"
4142
availability_zone = var.availability_zone
4243
charge_type = "POSTPAID_BY_HOUR"
4344
vpc_id = tencentcloud_vpc.vpc.id
4445
subnet_id = tencentcloud_subnet.subnet.id
45-
engine_version = "10.4"
46+
db_major_version = "10"
47+
engine_version = "10.23"
4648
root_user = "root123"
4749
root_password = "Root123$"
4850
charset = "UTF8"
4951
project_id = 0
52+
cpu = 1
5053
memory = 2
5154
storage = 10
5255
@@ -69,21 +72,21 @@ variable "standby_availability_zone" {
6972
7073
# create vpc
7174
resource "tencentcloud_vpc" "vpc" {
72-
name = "guagua_vpc_instance_test"
75+
name = "vpc"
7376
cidr_block = "10.0.0.0/16"
7477
}
7578
7679
# create vpc subnet
7780
resource "tencentcloud_subnet" "subnet" {
7881
availability_zone = var.availability_zone
79-
name = "guagua_vpc_subnet_test"
82+
name = "subnet"
8083
vpc_id = tencentcloud_vpc.vpc.id
8184
cidr_block = "10.0.20.0/28"
8285
is_multicast = false
8386
}
8487
8588
# create postgresql
86-
resource "tencentcloud_postgresql_instance" "foo" {
89+
resource "tencentcloud_postgresql_instance" "example" {
8790
name = "example"
8891
availability_zone = var.availability_zone
8992
charge_type = "POSTPAID_BY_HOUR"
@@ -102,6 +105,7 @@ resource "tencentcloud_postgresql_instance" "foo" {
102105
role = "Primary"
103106
zone = var.availability_zone
104107
}
108+
105109
db_node_set {
106110
zone = var.standby_availability_zone
107111
}
@@ -115,19 +119,23 @@ resource "tencentcloud_postgresql_instance" "foo" {
115119
### create pgsql with kms key
116120

117121
```hcl
118-
resource "tencentcloud_postgresql_instance" "pg" {
122+
variable "availability_zone" {
123+
default = "ap-guangzhou-6"
124+
}
125+
126+
resource "tencentcloud_postgresql_instance" "example" {
119127
name = "tf_postsql_instance"
120-
availability_zone = "ap-guangzhou-6"
128+
availability_zone = var.availability_zone
121129
charge_type = "POSTPAID_BY_HOUR"
122130
vpc_id = "vpc-86v957zb"
123131
subnet_id = "subnet-enm92y0m"
132+
db_major_version = "11"
124133
engine_version = "11.12"
125-
# db_major_vesion = "11"
126134
db_kernel_version = "v11.12_r1.3"
127135
need_support_tde = 1
128136
kms_key_id = "788c606a-c7b7-11ec-82d1-5254001e5c4e"
129137
kms_region = "ap-guangzhou"
130-
root_password = "xxxxxxxxxx"
138+
root_password = "Root123$"
131139
charset = "LATIN1"
132140
project_id = 0
133141
memory = 4
@@ -149,20 +157,25 @@ resource "tencentcloud_postgresql_instance" "pg" {
149157
### upgrade kernel version
150158

151159
```hcl
152-
resource "tencentcloud_postgresql_instance" "test" {
153-
name = "tf_postsql_instance_update"
154-
availability_zone = data.tencentcloud_availability_zones_by_product.zone.zones[5].name
160+
variable "availability_zone" {
161+
default = "ap-guangzhou-6"
162+
}
163+
164+
resource "tencentcloud_postgresql_instance" "example" {
165+
name = "tf_postsql_instance_update_kernel"
166+
availability_zone = var.availability_zone
155167
charge_type = "POSTPAID_BY_HOUR"
156-
vpc_id = local.vpc_id
157-
subnet_id = local.subnet_id
168+
vpc_id = "vpc-86v957zb"
169+
subnet_id = "subnet-enm92y0m"
158170
engine_version = "13.3"
159-
root_password = "*"
171+
root_password = "Root123$"
160172
charset = "LATIN1"
161173
project_id = 0
162174
public_access_switch = false
163-
security_groups = [local.sg_id]
175+
security_groups = ["sg-cm7fbbf3"]
164176
memory = 4
165177
storage = 250
178+
166179
backup_plan {
167180
min_backup_start_time = "01:10:11"
168181
max_backup_start_time = "02:10:11"
@@ -173,7 +186,7 @@ resource "tencentcloud_postgresql_instance" "test" {
173186
db_kernel_version = "v13.3_r1.4" # eg:from v13.3_r1.1 to v13.3_r1.4
174187
175188
tags = {
176-
tf = "teest"
189+
tf = "test"
177190
}
178191
}
179192
```
@@ -243,6 +256,6 @@ In addition to all arguments above, the following attributes are exported:
243256
postgresql instance can be imported using the id, e.g.
244257

245258
```
246-
$ terraform import tencentcloud_postgresql_instance.foo postgres-cda1iex1
259+
$ terraform import tencentcloud_postgresql_instance.example postgres-cda1iex1
247260
```
248261

0 commit comments

Comments
 (0)