@@ -7,11 +7,6 @@ resource "google_sql_database_instance" "instance" {
7
7
region = "us-central1"
8
8
settings {
9
9
tier = "db-f1-micro"
10
- backup_configuration {
11
- enabled = true
12
- binary_log_enabled = true
13
- }
14
-
15
10
ip_configuration {
16
11
17
12
// Datastream IPs will vary by region.
@@ -36,8 +31,7 @@ resource "google_sql_database_instance" "instance" {
36
31
}
37
32
}
38
33
}
39
-
40
- deletion_protection = {{index $.Vars "deletion_protection"}}
34
+ deletion_protection = {{index $.Vars "deletion_protection"}}
41
35
}
42
36
43
37
resource "google_sql_database" "db" {
@@ -57,6 +51,29 @@ resource "google_sql_user" "user" {
57
51
password = random_password.pwd.result
58
52
}
59
53
54
+ resource "google_storage_bucket" "blmt_bucket" {
55
+ # Use variable from Stream.yaml for the name
56
+ name = "{{index $.Vars "blmt_bucket_name"}}"
57
+ location = "us-central1"
58
+ force_destroy = true
59
+ }
60
+
61
+ resource "google_bigquery_connection" "blmt_connection" {
62
+ project = data.google_project.project.project_id
63
+ location = "us-central1"
64
+ connection_id = "{{index $.Vars "blmt_connection_id"}}"
65
+ friendly_name = "Datastream BLMT Test Connection"
66
+ description = "Connection for Datastream BLMT test"
67
+
68
+ cloud_resource {}
69
+ }
70
+
71
+ resource "google_storage_bucket_iam_member" "blmt_connection_bucket_admin" {
72
+ bucket = google_storage_bucket.blmt_bucket.name
73
+ role = "roles/storage.admin"
74
+ member = "serviceAccount:${google_bigquery_connection.blmt_connection.cloud_resource[0].service_account_id}"
75
+ }
76
+
60
77
resource "google_datastream_connection_profile" "source_connection_profile" {
61
78
display_name = "Source connection profile"
62
79
location = "us-central1"
@@ -80,7 +97,7 @@ resource "google_datastream_connection_profile" "destination_connection_profile"
80
97
resource "google_datastream_stream" "{{$.PrimaryResourceId}}" {
81
98
stream_id = "{{index $.Vars "stream_id"}}"
82
99
location = "us-central1"
83
- display_name = "my stream"
100
+ display_name = "My BLMT stream"
84
101
source_config {
85
102
source_connection_profile = google_datastream_connection_profile.source_connection_profile.id
86
103
mysql_source_config {}
@@ -94,11 +111,11 @@ resource "google_datastream_stream" "{{$.PrimaryResourceId}}" {
94
111
}
95
112
}
96
113
blmt_config {
97
- bucket = "{{index $.Vars " blmt_bucket"}}"
98
- connection_name = "{{index $.Vars "blmt_connection_name"} }"
99
- file_format = "{{index $.Vars "blmt_file_format"}} "
100
- table_format = "{{index $.Vars "blmt_table_format"}} "
101
- root_path = "{{index $.Vars "blmt_root_path"}} "
114
+ bucket = google_storage_bucket. blmt_bucket.name
115
+ connection_name = "${google_bigquery_connection.blmt_connection.project}.${google_bigquery_connection.blmt_connection.location}.${google_bigquery_connection.blmt_connection.connection_id }"
116
+ file_format = "PARQUET "
117
+ table_format = "ICEBERG "
118
+ root_path = "/ "
102
119
}
103
120
append_only {}
104
121
}
0 commit comments