forked from googleapis/google-cloud-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
48 lines (46 loc) · 1.54 KB
/
main.tf
File metadata and controls
48 lines (46 loc) · 1.54 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
terraform {
required_providers {
google = {
source = "hashicorp/google"
}
}
}
resource "google_project_service" "bigquery" {
service = "bigquery.googleapis.com"
project = var.inputs.project_id
count = var.inputs.should_enable_apis_on_apply ? 1 : 0
disable_on_destroy = var.inputs.should_disable_apis_on_destroy
}
resource "google_project_service" "bigqueryconnection" {
service = "bigqueryconnection.googleapis.com"
project = var.inputs.project_id
count = var.inputs.should_enable_apis_on_apply ? 1 : 0
disable_on_destroy = var.inputs.should_disable_apis_on_destroy
}
resource "google_project_service" "sqladmin" {
service = "sqladmin.googleapis.com"
project = var.inputs.project_id
count = var.inputs.should_enable_apis_on_apply ? 1 : 0
disable_on_destroy = var.inputs.should_disable_apis_on_destroy
}
resource "random_id" "id" {
byte_length = 3
}
locals {
db_name = lower("mysql-db-${random_id.id.hex}")
}
module "mysql-db" {
source = "GoogleCloudPlatform/sql-db/google//modules/mysql"
version = "12.0.0"
name = local.db_name
database_version = "MYSQL_8_0"
deletion_protection = false
project_id = var.inputs.project_id
zone = var.inputs.zone
region = var.inputs.region
depends_on = [
google_project_service.bigquery,
google_project_service.bigqueryconnection,
google_project_service.sqladmin
]
}