Skip to content

Commit d43e9bc

Browse files
committed
Updated the BLMT example
1 parent 95d2403 commit d43e9bc

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed

mmv1/products/datastream/Stream.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,20 @@ examples:
197197
external_providers: ["random", "time"]
198198
# Random provider
199199
skip_vcr: true
200+
- name: 'datastream_stream_bigquery_blmt'
201+
primary_resource_id: 'default'
202+
vars:
203+
stream_id: 'blmt-stream'
204+
database_instance_name: 'blmt-instance'
205+
deletion_protection: 'true'
206+
source_connection_profile_id: 'blmt-source-profile'
207+
destination_connection_profile_id: 'blmt-destination-profile'
208+
blmt_bucket_name: 'blmt-bucket'
209+
blmt_connection_id: 'blmt-connection'
210+
test_vars_overrides:
211+
'deletion_protection': 'false'
212+
external_providers: ["random"]
213+
skip_vcr: true
200214
virtual_fields:
201215
- name: 'desired_state'
202216
description: |

mmv1/templates/terraform/examples/datastream_stream_bigquery_blmt.tf.tmpl

+30-13
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ resource "google_sql_database_instance" "instance" {
77
region = "us-central1"
88
settings {
99
tier = "db-f1-micro"
10-
backup_configuration {
11-
enabled = true
12-
binary_log_enabled = true
13-
}
14-
1510
ip_configuration {
1611

1712
// Datastream IPs will vary by region.
@@ -36,8 +31,7 @@ resource "google_sql_database_instance" "instance" {
3631
}
3732
}
3833
}
39-
40-
deletion_protection = {{index $.Vars "deletion_protection"}}
34+
deletion_protection = {{index $.Vars "deletion_protection"}}
4135
}
4236

4337
resource "google_sql_database" "db" {
@@ -57,6 +51,29 @@ resource "google_sql_user" "user" {
5751
password = random_password.pwd.result
5852
}
5953

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+
6077
resource "google_datastream_connection_profile" "source_connection_profile" {
6178
display_name = "Source connection profile"
6279
location = "us-central1"
@@ -80,7 +97,7 @@ resource "google_datastream_connection_profile" "destination_connection_profile"
8097
resource "google_datastream_stream" "{{$.PrimaryResourceId}}" {
8198
stream_id = "{{index $.Vars "stream_id"}}"
8299
location = "us-central1"
83-
display_name = "my stream"
100+
display_name = "My BLMT stream"
84101
source_config {
85102
source_connection_profile = google_datastream_connection_profile.source_connection_profile.id
86103
mysql_source_config {}
@@ -94,11 +111,11 @@ resource "google_datastream_stream" "{{$.PrimaryResourceId}}" {
94111
}
95112
}
96113
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 = "/"
102119
}
103120
append_only {}
104121
}

0 commit comments

Comments
 (0)