|
| 1 | +/** |
| 2 | + * Copyright 2018 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 | +provider "google" { |
| 18 | + region = "europe-west1" |
| 19 | +} |
| 20 | + |
| 21 | +module "pub" { |
| 22 | + source = "terraform-google-modules/pubsub/google//modules/pub" |
| 23 | + version = "~> 7.0" |
| 24 | + |
| 25 | + project_id = var.project_id |
| 26 | + topic = "cft-tf-pub-topic-bigquery" |
| 27 | + topic_labels = { |
| 28 | + foo_label = "foo_value" |
| 29 | + bar_label = "bar_value" |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +module "sub" { |
| 34 | + source = "terraform-google-modules/pubsub/google//modules/sub" |
| 35 | + version = "~> 7.0" |
| 36 | + |
| 37 | + project_id = var.project_id |
| 38 | + topic = "cft-tf-pub-topic-bigquery" |
| 39 | + |
| 40 | + bigquery_subscriptions = [ |
| 41 | + { |
| 42 | + name = "sub_example_subscription" |
| 43 | + table = "${var.project_id}:sub_example_dataset.sub_example_table" |
| 44 | + }, |
| 45 | + ] |
| 46 | + |
| 47 | + depends_on = [ |
| 48 | + google_bigquery_table.test |
| 49 | + ] |
| 50 | + |
| 51 | +} |
| 52 | + |
| 53 | +resource "google_bigquery_dataset" "test" { |
| 54 | + project = var.project_id |
| 55 | + dataset_id = "sub_example_dataset" |
| 56 | + location = "europe-west1" |
| 57 | +} |
| 58 | + |
| 59 | +resource "google_bigquery_table" "test" { |
| 60 | + project = var.project_id |
| 61 | + deletion_protection = false |
| 62 | + table_id = "sub_example_table" |
| 63 | + dataset_id = google_bigquery_dataset.test.dataset_id |
| 64 | + |
| 65 | + schema = <<EOF |
| 66 | +[ |
| 67 | + { |
| 68 | + "name": "data", |
| 69 | + "type": "STRING", |
| 70 | + "mode": "NULLABLE", |
| 71 | + "description": "The data" |
| 72 | + } |
| 73 | +] |
| 74 | +EOF |
| 75 | +} |
0 commit comments