@@ -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,6 @@ resource "google_sql_database_instance" "instance" {
36
31
}
37
32
}
38
33
}
39
-
40
- deletion_protection = {{index $.Vars "deletion_protection"}}
41
34
}
42
35
43
36
resource "google_sql_database" "db" {
@@ -57,15 +50,40 @@ resource "google_sql_user" "user" {
57
50
password = random_password.pwd.result
58
51
}
59
52
53
+ resource "google_storage_bucket" "blmt_bucket" {
54
+ # Use variable from Stream.yaml for the name
55
+ name = "{{index $.Vars "blmt_bucket_name"}}"
56
+ location = "us-central1"
57
+ force_destroy = true
58
+
59
+ uniform_bucket_level_access = true
60
+ }
61
+
62
+ resource "google_bigquery_connection" "blmt_connection" {
63
+ project = data.google_project.project.project_id
64
+ location = "us-central1"
65
+ connection_id = "{{index $.Vars "blmt_connection_id"}}"
66
+ friendly_name = "Datastream BLMT Test Connection"
67
+ description = "Connection for Datastream BLMT test"
68
+
69
+ cloud_resource {}
70
+ }
71
+
72
+ resource "google_storage_bucket_iam_member" "blmt_connection_bucket_admin" {
73
+ bucket = google_storage_bucket.blmt_bucket.name
74
+ role = "roles/storage.admin"
75
+ member = "serviceAccount:${google_bigquery_connection.blmt_connection.cloud_resource[0].service_account_id}"
76
+ }
77
+
60
78
resource "google_datastream_connection_profile" "source_connection_profile" {
61
79
display_name = "Source connection profile"
62
80
location = "us-central1"
63
81
connection_profile_id = "{{index $.Vars "source_connection_profile_id"}}"
64
82
65
83
mysql_profile {
66
- hostname = google_sql_database_instance.instance.public_ip_address
67
- username = google_sql_user. user.name
68
- password = google_sql_user.user.password
84
+ hostname = "34.56.122.245"
85
+ username = " user"
86
+ password = "p123"
69
87
}
70
88
}
71
89
@@ -80,7 +98,7 @@ resource "google_datastream_connection_profile" "destination_connection_profile"
80
98
resource "google_datastream_stream" "{{$.PrimaryResourceId}}" {
81
99
stream_id = "{{index $.Vars "stream_id"}}"
82
100
location = "us-central1"
83
- display_name = "my stream"
101
+ display_name = "My BLMT stream"
84
102
source_config {
85
103
source_connection_profile = google_datastream_connection_profile.source_connection_profile.id
86
104
mysql_source_config {}
@@ -94,11 +112,11 @@ resource "google_datastream_stream" "{{$.PrimaryResourceId}}" {
94
112
}
95
113
}
96
114
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"}} "
115
+ bucket = google_storage_bucket. blmt_bucket.name
116
+ connection_name = "${google_bigquery_connection.blmt_connection.project}.${google_bigquery_connection.blmt_connection.location}.${google_bigquery_connection.blmt_connection.connection_id }"
117
+ file_format = "PARQUET "
118
+ table_format = "ICEBERG "
119
+ root_path = "/ "
102
120
}
103
121
append_only {}
104
122
}
0 commit comments