forked from turbaszek/snowplow-gcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnowplow.tf
166 lines (130 loc) · 3 KB
/
snowplow.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
variable "gcp_project" {}
variable "gcp_location" {}
variable "gcp_key_admin" {}
variable "client" {}
locals {
bq-loader = "bq-loader"
collector = "collector"
enrich = "enrich"
}
provider "google" {
credentials = file(var.gcp_key_admin)
project = var.gcp_project
region = var.gcp_location
}
resource "random_string" "random" {
length = 8
special = false
upper = false
}
######## BUCKETS
resource "google_storage_bucket" "config" {
name = "config-${var.client}-${random_string.random.result}"
location = var.gcp_location
bucket_policy_only = true
labels = {
snowplow = "true",
}
}
resource "google_storage_bucket" "sink" {
name = "temp-sink-${var.client}-${random_string.random.result}"
location = var.gcp_location
bucket_policy_only = true
labels = {
snowplow = "true",
component = local.enrich,
}
}
######## Pub/Sub
# Topics for the collector and enrich
# https://github.com/snowplow/snowplow/wiki/GCP:-Setting-up-the-Scala-Stream-Collector
resource "google_pubsub_topic" "good" {
name = "good"
labels = {
snowplow = "true",
component = local.collector,
}
}
resource "google_pubsub_topic" "enriched-good" {
name = "enriched-good"
labels = {
snowplow = "true",
component = local.enrich,
}
}
resource "google_pubsub_topic" "bad" {
name = "bad"
labels = {
snowplow = "true",
component = local.collector,
}
}
resource "google_pubsub_topic" "enriched-bad" {
name = "enriched-bad"
labels = {
snowplow = "true",
component = local.enrich,
}
}
resource "google_pubsub_subscription" "snowplow-enrich" {
name = "raw-good"
topic = google_pubsub_topic.good.name
labels = {
snowplow = "true",
component = local.enrich,
}
# 20 minutes
message_retention_duration = "1200s"
retain_acked_messages = true
ack_deadline_seconds = 20
expiration_policy {
ttl = "300000.5s"
}
}
######## BigQuery
locals {
datasetId = "snowplow"
tableId = "events"
}
resource "google_bigquery_dataset" "dataset" {
dataset_id = local.datasetId
friendly_name = "snowplow"
description = "Dataset used by Snowplow BigQuery loader."
location = var.gcp_location
labels = {
snowplow = "true",
component = local.bq-loader
}
}
######## GKE
resource "google_container_cluster" "gke" {
name = "snowplow-gke"
location = var.gcp_location
initial_node_count = 1
master_auth {
username = ""
password = ""
client_certificate_config {
issue_client_certificate = false
}
}
node_config {
oauth_scopes = [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/pubsub",
"https://www.googleapis.com/auth/cloud-platform",
]
metadata = {
disable-legacy-endpoints = "true"
}
labels = {
snowplow = "true"
}
tags = ["snowplow", "test"]
}
timeouts {
create = "30m"
update = "40m"
}
}