Skip to content

Commit 2cc8bbf

Browse files
committed
OPS: Add test BigQuery dataset to terraform config
1 parent 414699e commit 2cc8bbf

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

terraform/bigquery.tf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
resource "google_bigquery_dataset" "test_dataset" {
2+
dataset_id = "octue_sdk_python_test_dataset"
3+
description = "A dataset for testing BigQuery subscriptions for the Octue SDK."
4+
location = "EU"
5+
default_table_expiration_ms = 3600000
6+
7+
labels = {
8+
env = "default"
9+
}
10+
}
11+
12+
resource "google_bigquery_table" "test_table" {
13+
dataset_id = google_bigquery_dataset.test_dataset.dataset_id
14+
table_id = "question-events"
15+
16+
labels = {
17+
env = "default"
18+
}
19+
20+
schema = <<EOF
21+
[
22+
{
23+
"name": "subscription_name",
24+
"type": "STRING",
25+
"mode": "REQUIRED"
26+
},
27+
{
28+
"name": "message_id",
29+
"type": "STRING",
30+
"mode": "REQUIRED"
31+
},
32+
{
33+
"name": "publish_time",
34+
"type": "TIMESTAMP",
35+
"mode": "REQUIRED"
36+
},
37+
{
38+
"name": "data",
39+
"type": "JSON",
40+
"mode": "REQUIRED",
41+
"description": "Octue service event (e.g. heartbeat, log record, result)."
42+
},
43+
{
44+
"name": "attributes",
45+
"type": "JSON",
46+
"mode": "REQUIRED",
47+
"description": "Metadata for routing the event, adding context, and guiding the receiver's behaviour."
48+
}
49+
]
50+
EOF
51+
}

terraform/iam.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ resource "google_project_iam_binding" "errorreporting_writer" {
8282
}
8383

8484

85+
resource "google_project_iam_binding" "bigquery_dataeditor" {
86+
project = var.project
87+
role = "roles/bigquery.dataEditor"
88+
members = [
89+
"serviceAccount:service-${var.project_number}@gcp-sa-pubsub.iam.gserviceaccount.com",
90+
]
91+
}
92+
93+
8594
resource "google_iam_workload_identity_pool" "github_actions_pool" {
8695
display_name = "github-actions-pool"
8796
project = var.project

0 commit comments

Comments
 (0)