-
Notifications
You must be signed in to change notification settings - Fork 0
/
lake.tf.txt
82 lines (69 loc) · 2.11 KB
/
lake.tf.txt
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
# Definizione del bucket Cloud Storage per il livello L0 del Data Lakehouse
resource "google_storage_bucket" "raw_data_bucket" {
name = var.raw_data_bucket_name
location = var.region
versioning {
enabled = true
}
lifecycle_rule {
action {
type = "SetStorageClass"
storage_class = "NEARLINE"
}
condition {
age = 30
}
}
}
# Configurazione dell'istanza Cloud SQL per il livello L1 del Data Lakehouse
resource "google_sql_database_instance" "relational_db_instance" {
name = var.relational_db_instance_name
database_version = "MYSQL_5_7"
region = var.cloud_sql_location
project = var.project_id
settings {
tier = "db-f1-micro"
backup_configuration {
enabled = true
binary_log_enabled = true
start_time = "16:00"
}
database_flags {
name = "log_bin_trust_function_creators"
value = "on"
}
}
}
# Configurazione del dataset BigQuery per il livello L2 del Data Lakehouse
resource "google_bigquery_dataset" "analytic_dataset" {
dataset_id = var.analytic_dataset_id
location = var.bigquery_location
default_table_expiration_ms = 3600000
access {
role_entity = "WRITER"
user_by_email {
email = "user@example.com"
}
}
labels = {
environment = "production"
sensitivity = "high"
}
}
# Impostazione delle politiche di sicurezza di base per il livello L2 del Data Lakehouse
resource "google_bigquery_iam_binding" "dataset_iam_binding" {
dataset_id = google_bigquery_dataset.analytic_dataset.dataset_id
role = "roles/bigquery.dataOwner"
members = [
"serviceAccount:${google_service_account.manipulation_service_account.email}",
]
}
# Configurazione delle etichette di sicurezza per il dataset BigQuery
resource "google_bigquery_resource_label" "analytic_dataset_labels" {
resource_type = "dataset"
resource_id = google_bigquery_dataset.analytic_dataset.dataset_id
labels = {
environment = "production"
sensitivity = "high"
}
}