...
1/**
2 * Copyright 2022 Google LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17```hcl
18resource "google_datastream_connection_profile" "source" {
19 display_name = "Postgresql Source"
20 location = "us-central1"
21 connection_profile_id = "source-profile"
22
23 postgresql_profile {
24 hostname = "hostname"
25 port = 3306
26 username = "user"
27 password = "pass"
28 database = "postgres"
29 }
30}
31
32resource "google_datastream_connection_profile" "destination" {
33 display_name = "BigQuery Destination"
34 location = "us-central1"
35 connection_profile_id = "destination-profile"
36
37 bigquery_profile {}
38}
39
40resource "google_datastream_stream" "default" {
41 display_name = "Postgres to BigQuery"
42 location = "us-central1"
43 stream_id = "my-stream"
44 desired_state = "RUNNING"
45
46 source_config {
47 source_connection_profile = google_datastream_connection_profile.source.id
48 postgresql_source_config {
49 max_concurrent_backfill_tasks = 12
50 publication = "publication"
51 replication_slot = "replication_slot"
52 include_objects {
53 postgresql_schemas {
54 schema = "schema"
55 postgresql_tables {
56 table = "table"
57 postgresql_columns {
58 column = "column"
59 }
60 }
61 }
62 }
63 exclude_objects {
64 postgresql_schemas {
65 schema = "schema"
66 postgresql_tables {
67 table = "table"
68 postgresql_columns {
69 column = "column"
70 }
71 }
72 }
73 }
74 }
75 }
76
77 destination_config {
78 destination_connection_profile = google_datastream_connection_profile.destination.id
79 bigquery_destination_config {
80 data_freshness = "900s"
81 source_hierarchy_datasets {
82 dataset_template {
83 location = "us-central1"
84 }
85 }
86 }
87 }
88
89 backfill_all {
90 postgresql_excluded_objects {
91 postgresql_schemas {
92 schema = "schema"
93 postgresql_tables {
94 table = "table"
95 postgresql_columns {
96 column = "column"
97 }
98 }
99 }
100 }
101 }
102}
103```
View as plain text