-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
195 lines (176 loc) · 5.45 KB
/
Copy pathvariables.tf
File metadata and controls
195 lines (176 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
variable "postgres_version" {
type = string
default = "17"
description = <<EOF
Specify the postgres engine to utilize.
Supported versions are 13, 14, 15, 16, 17, and 18.
By default, configured with 17.
EOF
}
variable "edition" {
type = string
default = "ENTERPRISE"
description = <<EOF
By default, this is set to 'ENTERPRISE' which suits non-production environments.
For production environments, it is recommended to set this to 'ENTERPRISE_PLUS'.
EOF
validation {
condition = contains(["ENTERPRISE", "ENTERPRISE_PLUS"], var.edition)
error_message = "edition must be either 'ENTERPRISE' or 'ENTERPRISE_PLUS'"
}
}
variable "instance_class" {
type = string
default = "db-f1-micro"
description = <<EOF
The machine type to use.
By default, configured with db-f1-micro.
Available options:
db-f1-micro
db-g1-small
db-n1-standard-1
db-n1-standard-2
db-n1-standard-4
db-n1-standard-8
db-n1-standard-16
db-n1-standard-32
db-n1-standard-64
db-n1-standard-96
db-n1-highmem-2
db-n1-highmem-4
db-n1-highmem-8
db-n1-highmem-16
db-n1-highmem-32
db-n1-highmem-64
db-n1-highmem-96
EOF
}
variable "allocated_storage" {
type = number
default = 10
description = "Allocated storage in GB"
}
variable "backup_retention_count" {
type = number
default = 7
description = "The number of backups that are retained"
}
variable "maintenance_window" {
type = object({
day : number
hour : number
})
default = {
day = 7
hour = 23
}
description = <<EOF
Configuration for maintenance window.
Day of week => 1-7 starts on Monday.
Hour of day => 0-23.
By default, configured for Sunday at 11:00 PM.
EOF
}
variable "high_availability" {
type = bool
default = false
description = <<EOF
Enables high availability and failover support on the database instance.
By default, this is disabled. It is recommended to enable this in production environments.
In dev environments, it is best to turn off to save on costs.
EOF
}
variable "enforce_ssl" {
type = bool
default = false
description = <<EOF
By default, the postgres cluster will have SSL enabled.
This toggle will require an SSL connection.
This is highly recommended if you have public access enabled.
EOF
}
variable "enforce_secure_passwords" {
type = bool
default = false
description = <<EOF
This enables a secure password policy on the database instance.
Specifically, this requires a minimum password length of 8 characters, a complexity of DEFAULT, a reuse interval of 5 days, disallowing the username in the password, and a password change interval of 0 seconds.
By default, this is disabled.
EOF
}
variable "point_in_time_recovery_enabled" {
type = bool
default = false
description = <<EOF
Enables point-in-time recovery (PITR) on the database instance.
PITR lets you restore the database to a specific moment, which is useful for recovering from accidental data loss.
By default, this is disabled. It is recommended to enable this in production environments.
EOF
}
variable "deletion_protection_enabled" {
type = bool
default = false
description = <<EOF
Protects the database instance from accidental deletion.
When enabled, the instance cannot be deleted until this is disabled, at both the Terraform and GCP API levels.
By default, this is disabled. It is recommended to enable this in production environments.
EOF
}
variable "enable_public_access" {
type = bool
default = false
description = <<EOF
By default, the postgres cluster is not accessible to the public.
If you want to access your database, we recommend using a bastion instead.
EOF
}
variable "enable_psc" {
type = bool
default = false
description = <<EOF
Enables connectivity to this postgres instance via Private Service Connect (PSC) instead of the default private services access (PSA).
PSC is useful when you need to reach the database from a different VPC or project, or want centralized, per-consumer connectivity.
When enabled, public access is forced off (it is mutually exclusive with PSC).
By default, this is disabled and the instance uses private services access.
NOTE: Switching an existing instance between PSA and PSC forces the instance to be replaced (destructive). Plan a backup/restore or migration before toggling this on an existing datastore.
EOF
}
variable "db_flags" {
type = map(string)
default = {}
description = <<EOF
This is a dictionary of database flags to configure the postgres instance.
For a list of flags, see https://cloud.google.com/sql/docs/postgres/flags#list-flags-postgres
EOF
}
variable "ip_whitelist" {
type = set(string)
default = []
description = <<EOF
Specify a set of IP addresses that allowed to access this postgres instance without exposing public access.
EOF
}
variable "resource_thresholds" {
type = object({
cpu = number
memory = number
io_read = number
io_write = number
disk_low = number
disk_critical = number
})
default = {
cpu = 80
memory = 85
io_read = 1000
io_write = 1000
disk_low = 85
disk_critical = 95
}
description = <<EOF
Enables alerts on resource usage for the postgres instance.
Each alert is configured to trigger when the resource usage exceeds the specified threshold.
The thresholds are specified as percentages. (i.e. 80 => 80%)
However, io_read and io_write are specified in ops per second.
EOF
}