-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
43 lines (36 loc) · 859 Bytes
/
main.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
resource "random_password" "password" {
length = 22
special = true
}
resource "google_sql_database_instance" "master" {
name = var.instance_name
project = var.gcp_project
region = var.region
database_version = "POSTGRES_11"
deletion_protection = false
settings {
tier = "db-f1-micro"
ip_configuration {
ipv4_enabled = true
authorized_networks {
name = "internet"
value = "0.0.0.0/0"
}
}
}
}
resource "google_sql_user" "users" {
name = var.username
project = var.gcp_project
instance = google_sql_database_instance.master.name
password = random_password.password.result
}
resource "vault_generic_secret" "example" {
path = "secret/demo-user"
data_json = <<EOT
{
"user": "${google_sql_user.users.name}",
"password": "${random_password.password.result}"
}
EOT
}