-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
62 lines (46 loc) · 1.74 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
resource "google_storage_bucket" "ave-bucket-test1" {
name = "ave-bucket-test1"
location = "EU"
}
resource "google_bigquery_dataset" "terraform-test" {
dataset_id = var.dataset_id
project = var.project_id
friendly_name = "terraform-test"
description = "terraformed test dataset"
location = "EU"
default_table_expiration_ms = 3600000
labels = {
env = terraform.workspace
}
}
resource "google_bigquery_dataset" "view_dataset" {
dataset_id = var.view_dataset_id
project = var.project_id
friendly_name = var.view_dataset_id
description = "view dataset"
location = "EU"
default_table_expiration_ms = 3600000
labels = {
env = terraform.workspace
}
}
resource "google_bigquery_table" "test_table" {
for_each = fileset("${path.module}/TABLES", "*.json")
dataset_id = var.dataset_id
table_id = trimsuffix(each.value, ".json")
project = var.project_id
schema = file("${path.module}/TABLES/${each.value}")
labels = {
env = terraform.workspace
}
}
module "bq_view" {
for_each = fileset("./TABLES/", "*.json")
source = "[email protected]:averbekedgc/terraform_test.git//modules/bq_view"
#source = "./modules/bq_view"
project_id = var.project_id
view_dataset_id = var.view_dataset_id
view_id = trimsuffix("${each.key}", ".json")
query = "SELECT * FROM ${var.dataset_id}.${trimsuffix("${each.key}", ".json")}"
depends_on = [google_bigquery_dataset.terraform-test, google_bigquery_dataset.view_dataset, google_bigquery_table.test_table]
}