From c2ead6f0d40a136863c7befd8088d990de2855e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=A2=E9=B9=8F?= Date: Mon, 17 May 2021 13:44:41 -0400 Subject: [PATCH] feat: Add dicom bq support (#48) --- README.md | 2 +- examples/simple_example/main.tf | 15 +++++++++++++++ examples/simple_example/versions.tf | 4 ++-- main.tf | 11 +++++++++++ test/fixtures/simple_example/versions.tf | 4 ++-- .../integration/simple_example/controls/gcloud.rb | 15 +++++++++++++++ test/setup/versions.tf | 4 ++-- 7 files changed, 48 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..59902a3 100644 --- a/examples/simple_example/main.tf +++ b/examples/simple_example/main.tf @@ -25,6 +25,13 @@ 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" + project = var.project + deletion_protection = false +} + module "pubsub" { source = "terraform-google-modules/pubsub/google" version = "~> 1.8" @@ -61,6 +68,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..702c462 100644 --- a/test/integration/simple_example/controls/gcloud.rb +++ b/test/integration/simple_example/controls/gcloud.rb @@ -34,6 +34,21 @@ 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 + + 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 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" } + its(:stdout) { should include "bq://#{attribute("project")}.example_dataset.example_table" } 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" } }