Skip to content

Commit

Permalink
feat: Add dicom bq support (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaopeng authored May 17, 2021
1 parent 756449c commit c2ead6f
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions examples/simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions examples/simple_example/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
11 changes: 11 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" {
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/simple_example/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
15 changes: 15 additions & 0 deletions test/integration/simple_example/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/setup/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit c2ead6f

Please sign in to comment.