-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabases.tf
51 lines (47 loc) · 1.54 KB
/
databases.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
# Terraform code for database clusters (back-end subnet)
resource "google_sql_database" "clprimary" {
name = "mysql-cluster"
instance = google_sql_database_instance.db_instance.name
}
resource "google_sql_database_instance" "db_instance" {
project = var.gcp_project
region = var.gcp_region
name = "mysql-database"
database_version = "MYSQL_5_7"
settings {
tier = "db-f1-micro"
disk_size = 10
disk_type = "PD_SSD"
availability_type = "ZONAL"
ip_configuration {
ipv4_enabled = true
// Wide open ***FOR TROUBLESHOOTING ONLY***
// Note: This requires policy "sql.restrictAuthorizedNetwork" to be disabled for the project.
authorized_networks {
name = "tfpgv2-vpc"
value = "0.0.0.0/0"
}
// For use with Google Privarte Service Connect (PSC)
// private_network = google_compute_network.vpc.self_link
}
}
deletion_protection = false
}
resource "google_sql_user" "users" {
name = var.db_user
instance = google_sql_database_instance.db_instance.name
password = var.db_password
}
# Output relevant information (for debug) about the database instance
output "database_name" {
value = google_sql_database.clprimary.name
}
output "connection_name" {
value = google_sql_database_instance.db_instance.connection_name
}
output "db_public_ip" {
value = google_sql_database_instance.db_instance.public_ip_address
}
output "db_private_ip" {
value = google_sql_database_instance.db_instance.private_ip_address
}