-
Notifications
You must be signed in to change notification settings - Fork 135
/
database.tf
66 lines (60 loc) · 1.65 KB
/
database.tf
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
#
# CloudSQL Postgres Database
#
# CloudSQL requires that a fairly long, unspecified amount of time
# passes before a database name can be reused. To ease testing where
# we create and destroy databases a lot, we append 4 random digits to
# the database name.
resource "random_integer" "dbname" {
min = 1000
max = 9999
keepers = {
indexer = "${var.indexer}"
}
}
resource "google_sql_database_instance" "graph" {
database_version = "POSTGRES_12"
name = "${var.indexer}-${random_integer.dbname.result}"
settings {
activation_policy = "ALWAYS"
availability_type = "ZONAL"
disk_autoresize = true
disk_size = 100
disk_type = "PD_SSD"
tier = var.database_tier
ip_configuration {
ipv4_enabled = false
private_network = "projects/${var.project}/global/networks/default"
}
backup_configuration {
binary_log_enabled = false
enabled = true
start_time = "02:00"
}
database_flags {
name = "log_temp_files"
value = "-1"
}
database_flags {
name = "log_lock_waits"
value = "on"
}
}
}
resource "google_sql_database" "graph" {
name = "graph"
instance = google_sql_database_instance.graph.name
}
resource "google_sql_database" "indexer-service" {
name = "indexer-service"
instance = google_sql_database_instance.graph.name
}
resource "google_sql_database" "vector" {
name = "vector"
instance = google_sql_database_instance.graph.name
}
resource "google_sql_user" "graph" {
name = "graph"
instance = google_sql_database_instance.graph.name
password = var.database_password
}