-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.tf
More file actions
40 lines (34 loc) · 992 Bytes
/
Copy pathsql.tf
File metadata and controls
40 lines (34 loc) · 992 Bytes
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
resource "google_sql_database_instance" "primary" {
provider = google-beta
name = "sql-${random_id.unique.hex}"
depends_on = [google_service_networking_connection.sql]
database_version = "POSTGRES_11"
settings {
availability_type = "REGIONAL"
disk_size = 4096
tier = "db-custom-${var.cpus}-${var.cpus * 4 * 1024}"
ip_configuration {
ipv4_enabled = false
private_network = google_compute_network.primary.self_link
}
backup_configuration {
enabled = false
}
location_preference {
zone = data.google_compute_zones.available.names[0]
}
}
}
resource "google_sql_database" "database" {
name = "test"
instance = google_sql_database_instance.primary.name
}
resource "random_password" "sql-test" {
length = 16
special = false
}
resource "google_sql_user" "test" {
name = "test"
instance = google_sql_database_instance.primary.name
password = random_password.sql-test.result
}