From 2a29ae015463d00411a17ffcf3395a0cd87e1c42 Mon Sep 17 00:00:00 2001 From: chaopeng Date: Thu, 13 May 2021 11:44:30 -0400 Subject: [PATCH 1/7] add dicom bq support --- README.md | 2 +- examples/simple_example/main.tf | 13 +++++++++++++ examples/simple_example/versions.tf | 4 ++-- main.tf | 11 +++++++++++ test/fixtures/simple_example/versions.tf | 4 ++-- test/integration/simple_example/controls/gcloud.rb | 1 + test/setup/versions.tf | 4 ++-- 7 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 693b015..d66281d 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ These sections describe requirements for using this module. The following dependencies must be available: - [Terraform][terraform] v0.13 -- [Terraform Provider for GCP][terraform-provider-gcp] plugin v3.54.0 +- [Terraform Provider for GCP][terraform-provider-gcp] plugin v3.67.0 ### Service Account diff --git a/examples/simple_example/main.tf b/examples/simple_example/main.tf index 13fbafe..f9fa634 100644 --- a/examples/simple_example/main.tf +++ b/examples/simple_example/main.tf @@ -25,6 +25,11 @@ resource "google_bigquery_dataset" "example_dataset" { project = var.project } +resource "google_bigquery_table" "example_table" { + dataset_id = google_bigquery_dataset.example_dataset.dataset_id + table_id = "example_table" +} + module "pubsub" { source = "terraform-google-modules/pubsub/google" version = "~> 1.8" @@ -61,6 +66,14 @@ module "healthcare" { role = "roles/healthcare.dicomEditor" member = local.sa_member }] + }, + { + name = "example-dicom-c" + stream_configs = [{ + bigquery_destination = { + table_uri = "bq://${var.project}.${google_bigquery_dataset.example_dataset.dataset_id}.${google_bigquery_table.example_table.table_id}" + } + }] } ] fhir_stores = [ diff --git a/examples/simple_example/versions.tf b/examples/simple_example/versions.tf index 1ad9a5d..3f3bbc5 100644 --- a/examples/simple_example/versions.tf +++ b/examples/simple_example/versions.tf @@ -17,7 +17,7 @@ terraform { required_version = ">= 0.13" required_providers { - google = ">= 3.54.0" - google-beta = ">= 3.54.0" + google = ">= 3.67.0" + google-beta = ">= 3.67.0" } } diff --git a/main.tf b/main.tf index 5b63201..6a59c59 100644 --- a/main.tf +++ b/main.tf @@ -22,6 +22,8 @@ resource "google_healthcare_dataset" "dataset" { } resource "google_healthcare_dicom_store" "dicom_stores" { + provider = google-beta + for_each = { for s in var.dicom_stores : s.name => s @@ -38,6 +40,15 @@ resource "google_healthcare_dicom_store" "dicom_stores" { } } + dynamic "stream_configs" { + for_each = lookup(each.value, "stream_configs", []) + + content { + bigquery_destination { + table_uri = stream_configs.value.bigquery_destination.table_uri + } + } + } } resource "google_healthcare_fhir_store" "fhir_stores" { diff --git a/test/fixtures/simple_example/versions.tf b/test/fixtures/simple_example/versions.tf index 1ad9a5d..3f3bbc5 100644 --- a/test/fixtures/simple_example/versions.tf +++ b/test/fixtures/simple_example/versions.tf @@ -17,7 +17,7 @@ terraform { required_version = ">= 0.13" required_providers { - google = ">= 3.54.0" - google-beta = ">= 3.54.0" + google = ">= 3.67.0" + google-beta = ">= 3.67.0" } } diff --git a/test/integration/simple_example/controls/gcloud.rb b/test/integration/simple_example/controls/gcloud.rb index f9b6890..e6264dd 100644 --- a/test/integration/simple_example/controls/gcloud.rb +++ b/test/integration/simple_example/controls/gcloud.rb @@ -34,6 +34,7 @@ its(:stderr) { should eq "" } its(:stdout) { should include "example-dicom-a" } its(:stdout) { should include "example-dicom-b" } + its(:stdout) { should include "example-dicom-c" } end # FHIR stores diff --git a/test/setup/versions.tf b/test/setup/versions.tf index d777685..9e2dcb0 100644 --- a/test/setup/versions.tf +++ b/test/setup/versions.tf @@ -17,7 +17,7 @@ terraform { required_version = ">= 0.13" required_providers { - google = ">= 3.54.0" - google-beta = ">= 3.54.0" + google = ">= 3.67.0" + google-beta = ">= 3.67.0" } } From 26d76bb9cd9131df1ea4f1ee2dc89c0201de2cbc Mon Sep 17 00:00:00 2001 From: chaopeng Date: Thu, 13 May 2021 12:00:16 -0400 Subject: [PATCH 2/7] fix bq table creation --- examples/simple_example/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/simple_example/main.tf b/examples/simple_example/main.tf index f9fa634..3975167 100644 --- a/examples/simple_example/main.tf +++ b/examples/simple_example/main.tf @@ -28,6 +28,7 @@ resource "google_bigquery_dataset" "example_dataset" { resource "google_bigquery_table" "example_table" { dataset_id = google_bigquery_dataset.example_dataset.dataset_id table_id = "example_table" + deletion_protection = false } module "pubsub" { From 9acb88696d1d11dd60675cc013ac023227a187b8 Mon Sep 17 00:00:00 2001 From: chaopeng Date: Thu, 13 May 2021 12:00:54 -0400 Subject: [PATCH 3/7] fix bq table creation --- examples/simple_example/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/simple_example/main.tf b/examples/simple_example/main.tf index 3975167..7ded035 100644 --- a/examples/simple_example/main.tf +++ b/examples/simple_example/main.tf @@ -28,7 +28,7 @@ resource "google_bigquery_dataset" "example_dataset" { resource "google_bigquery_table" "example_table" { dataset_id = google_bigquery_dataset.example_dataset.dataset_id table_id = "example_table" - deletion_protection = false + project = var.project } module "pubsub" { From 78d2963ec1cc9d233cab40feb0589ddeb3a1ebf3 Mon Sep 17 00:00:00 2001 From: chaopeng Date: Thu, 13 May 2021 12:13:58 -0400 Subject: [PATCH 4/7] fix bq table creation --- examples/simple_example/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/simple_example/main.tf b/examples/simple_example/main.tf index 7ded035..ce3b6ee 100644 --- a/examples/simple_example/main.tf +++ b/examples/simple_example/main.tf @@ -28,7 +28,7 @@ resource "google_bigquery_dataset" "example_dataset" { resource "google_bigquery_table" "example_table" { dataset_id = google_bigquery_dataset.example_dataset.dataset_id table_id = "example_table" - project = var.project + project = var.project } module "pubsub" { From 36d354781e60467f017db64016c7ade205296267 Mon Sep 17 00:00:00 2001 From: chaopeng Date: Thu, 13 May 2021 12:24:19 -0400 Subject: [PATCH 5/7] fix bq table creation --- examples/simple_example/main.tf | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/simple_example/main.tf b/examples/simple_example/main.tf index ce3b6ee..59902a3 100644 --- a/examples/simple_example/main.tf +++ b/examples/simple_example/main.tf @@ -26,9 +26,10 @@ resource "google_bigquery_dataset" "example_dataset" { } resource "google_bigquery_table" "example_table" { - dataset_id = google_bigquery_dataset.example_dataset.dataset_id - table_id = "example_table" - project = var.project + dataset_id = google_bigquery_dataset.example_dataset.dataset_id + table_id = "example_table" + project = var.project + deletion_protection = false } module "pubsub" { From a13313fd93ce3bf05f31af97427b30c054ff2184 Mon Sep 17 00:00:00 2001 From: chaopeng Date: Thu, 13 May 2021 13:06:04 -0400 Subject: [PATCH 6/7] add bq validation --- test/integration/simple_example/controls/gcloud.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/integration/simple_example/controls/gcloud.rb b/test/integration/simple_example/controls/gcloud.rb index e6264dd..0759cdb 100644 --- a/test/integration/simple_example/controls/gcloud.rb +++ b/test/integration/simple_example/controls/gcloud.rb @@ -37,6 +37,20 @@ its(:stdout) { should include "example-dicom-c" } end + describe command("gcloud --project=#{attribute("project")} healthcare dicom-stores describe example-dicom-a --dataset=example-healthcare-dataset") do + its(:exit_status) { should eq 0 } + its(:stderr) { should eq "" } + its(:stdout) { should include "notificationConfig" } + its(:stdout) { should include "projects/#{attribute("project")}/topics/example-topic\n" } + end + + describe command("gcloud --project=#{attribute("project")} healthcare dicom-stores describe example-dicom-c --dataset=example-healthcare-dataset") do + its(:exit_status) { should eq 0 } + its(:stderr) { should eq "" } + its(:stdout) { should include "streamConfigs" } + its(:stdout) { should include "bq://#{attribute("project")}.example_dataset.example_table" } + end + # FHIR stores describe command("gcloud --project=#{attribute("project")} healthcare fhir-stores list --dataset=example-healthcare-dataset") do its(:exit_status) { should eq 0 } From 157b67badc906ac27968c45b6265639127cd43d7 Mon Sep 17 00:00:00 2001 From: chaopeng Date: Thu, 13 May 2021 13:15:04 -0400 Subject: [PATCH 7/7] add bq validation --- test/integration/simple_example/controls/gcloud.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/simple_example/controls/gcloud.rb b/test/integration/simple_example/controls/gcloud.rb index 0759cdb..702c462 100644 --- a/test/integration/simple_example/controls/gcloud.rb +++ b/test/integration/simple_example/controls/gcloud.rb @@ -44,7 +44,7 @@ its(:stdout) { should include "projects/#{attribute("project")}/topics/example-topic\n" } end - describe command("gcloud --project=#{attribute("project")} healthcare dicom-stores describe example-dicom-c --dataset=example-healthcare-dataset") do + describe command("gcloud beta --project=#{attribute("project")} healthcare dicom-stores describe example-dicom-c --dataset=example-healthcare-dataset") do its(:exit_status) { should eq 0 } its(:stderr) { should eq "" } its(:stdout) { should include "streamConfigs" }