Skip to content

Commit 847bf5b

Browse files
committed
Updated the BLMT test
1 parent 95d2403 commit 847bf5b

File tree

2 files changed

+48
-16
lines changed

2 files changed

+48
-16
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

+34-16
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,6 @@ resource "google_sql_database_instance" "instance" {
3631
}
3732
}
3833
}
39-
40-
deletion_protection = {{index $.Vars "deletion_protection"}}
4134
}
4235

4336
resource "google_sql_database" "db" {
@@ -57,15 +50,40 @@ resource "google_sql_user" "user" {
5750
password = random_password.pwd.result
5851
}
5952

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+
6078
resource "google_datastream_connection_profile" "source_connection_profile" {
6179
display_name = "Source connection profile"
6280
location = "us-central1"
6381
connection_profile_id = "{{index $.Vars "source_connection_profile_id"}}"
6482

6583
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"
6987
}
7088
}
7189

@@ -80,7 +98,7 @@ resource "google_datastream_connection_profile" "destination_connection_profile"
8098
resource "google_datastream_stream" "{{$.PrimaryResourceId}}" {
8199
stream_id = "{{index $.Vars "stream_id"}}"
82100
location = "us-central1"
83-
display_name = "my stream"
101+
display_name = "My BLMT stream"
84102
source_config {
85103
source_connection_profile = google_datastream_connection_profile.source_connection_profile.id
86104
mysql_source_config {}
@@ -94,11 +112,11 @@ resource "google_datastream_stream" "{{$.PrimaryResourceId}}" {
94112
}
95113
}
96114
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 = "/"
102120
}
103121
append_only {}
104122
}

0 commit comments

Comments
 (0)