-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
103 lines (85 loc) · 2.33 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
provider "google" {
}
locals {
instance_name = format("%s-%s", var.instance_name, substr(md5(module.gce-container.container.image), 0, 8))
}
resource "google_project_service" "project" {
project = "rosy-crawler-389806"
service = "sqladmin.googleapis.com"
timeouts {
create = "30m"
update = "40m"
}
disable_dependent_services = true
}
module "gce-container" {
source = "terraform-google-modules/container-vm/google"
version = "~> 2.0"
cos_image_name = var.cos_image_name
container = {
image="ghcr.io/cloudquery/cloudquery:3.5.4"
}
restart_policy = "Always"
}
module "postgresql-db" {
source = "GoogleCloudPlatform/sql-db/google//modules/postgresql"
name = var.db_name
random_instance_name = true
database_version = "POSTGRES_9_6"
deletion_protection = false
project_id = var.project_id
zone = var.zone
region = "europe-west1"
ip_configuration = {
ipv4_enabled = true
private_network = null
require_ssl = true
allocated_ip_range = null
authorized_networks = var.authorized_networks
}
additional_databases = [
{
name = "cloudquery"
charset = "UTF8"
collation = "en_US.UTF8"
}
]
additional_users = [
{
name = "cloudquery"
host = "localhost"
random_password = true
},
]
}
resource "google_compute_instance" "vm" {
project = var.project_id
name = local.instance_name
machine_type = "n1-standard-1"
zone = var.zone
boot_disk {
initialize_params {
image = module.gce-container.source_image
}
}
network_interface {
subnetwork_project = var.subnetwork_project
subnetwork = var.subnetwork
access_config {}
}
tags = ["cloudquery-container"]
metadata = {
gce-container-declaration = module.gce-container.metadata_value
google-logging-enabled = "true"
google-monitoring-enabled = "true"
}
labels = {
container-vm = module.gce-container.vm_container_label
}
service_account {
email = var.client_email
scopes = [
"https://www.googleapis.com/auth/cloud-platform",
]
}
}