Skip to content

Commit 95d2403

Browse files
committed
Added blmt example
1 parent dfbad4d commit 95d2403

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
data "google_project" "project" {
2+
}
3+
4+
resource "google_sql_database_instance" "instance" {
5+
name = "{{index $.Vars "database_instance_name"}}"
6+
database_version = "MYSQL_8_0"
7+
region = "us-central1"
8+
settings {
9+
tier = "db-f1-micro"
10+
backup_configuration {
11+
enabled = true
12+
binary_log_enabled = true
13+
}
14+
15+
ip_configuration {
16+
17+
// Datastream IPs will vary by region.
18+
authorized_networks {
19+
value = "34.71.242.81"
20+
}
21+
22+
authorized_networks {
23+
value = "34.72.28.29"
24+
}
25+
26+
authorized_networks {
27+
value = "34.67.6.157"
28+
}
29+
30+
authorized_networks {
31+
value = "34.67.234.134"
32+
}
33+
34+
authorized_networks {
35+
value = "34.72.239.218"
36+
}
37+
}
38+
}
39+
40+
deletion_protection = {{index $.Vars "deletion_protection"}}
41+
}
42+
43+
resource "google_sql_database" "db" {
44+
instance = google_sql_database_instance.instance.name
45+
name = "db"
46+
}
47+
48+
resource "random_password" "pwd" {
49+
length = 16
50+
special = false
51+
}
52+
53+
resource "google_sql_user" "user" {
54+
name = "user"
55+
instance = google_sql_database_instance.instance.name
56+
host = "%"
57+
password = random_password.pwd.result
58+
}
59+
60+
resource "google_datastream_connection_profile" "source_connection_profile" {
61+
display_name = "Source connection profile"
62+
location = "us-central1"
63+
connection_profile_id = "{{index $.Vars "source_connection_profile_id"}}"
64+
65+
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
69+
}
70+
}
71+
72+
resource "google_datastream_connection_profile" "destination_connection_profile" {
73+
display_name = "Connection profile"
74+
location = "us-central1"
75+
connection_profile_id = "{{index $.Vars "destination_connection_profile_id"}}"
76+
77+
bigquery_profile {}
78+
}
79+
80+
resource "google_datastream_stream" "{{$.PrimaryResourceId}}" {
81+
stream_id = "{{index $.Vars "stream_id"}}"
82+
location = "us-central1"
83+
display_name = "my stream"
84+
source_config {
85+
source_connection_profile = google_datastream_connection_profile.source_connection_profile.id
86+
mysql_source_config {}
87+
}
88+
destination_config {
89+
destination_connection_profile = google_datastream_connection_profile.destination_connection_profile.id
90+
bigquery_destination_config {
91+
source_hierarchy_datasets {
92+
dataset_template {
93+
location = "us-central1"
94+
}
95+
}
96+
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"}}"
102+
}
103+
append_only {}
104+
}
105+
}
106+
107+
backfill_none {
108+
}
109+
}

0 commit comments

Comments
 (0)