Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support healthcare fhir new notifications config #12646

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/6471.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
healthcare: added `notification_configs ` field to `google_healthcare_fhir_store` resource
```
58 changes: 58 additions & 0 deletions google/resource_healthcare_fhir_store_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,64 @@ resource "google_bigquery_dataset" "bq_dataset" {
`, context)
}

func TestAccHealthcareFhirStore_healthcareFhirStoreNotificationConfigExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckHealthcareFhirStoreDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccHealthcareFhirStore_healthcareFhirStoreNotificationConfigExample(context),
},
{
ResourceName: "google_healthcare_fhir_store.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"self_link", "dataset"},
},
},
})
}

func testAccHealthcareFhirStore_healthcareFhirStoreNotificationConfigExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_healthcare_fhir_store" "default" {
name = "tf-test-example-fhir-store%{random_suffix}"
dataset = google_healthcare_dataset.dataset.id
version = "R4"

enable_update_create = false
disable_referential_integrity = false
disable_resource_versioning = false
enable_history_import = false

labels = {
label1 = "labelvalue1"
}

notification_configs {
pubsub_topic = "${google_pubsub_topic.topic.id}"
send_full_resource = true
}
}

resource "google_pubsub_topic" "topic" {
name = "tf-test-fhir-notifications%{random_suffix}"
}

resource "google_healthcare_dataset" "dataset" {
name = "tf-test-example-dataset%{random_suffix}"
location = "us-central1"
}
`, context)
}

func testAccCheckHealthcareFhirStoreDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
Expand Down
62 changes: 62 additions & 0 deletions website/docs/r/healthcare_fhir_store.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,44 @@ resource "google_bigquery_dataset" "bq_dataset" {
delete_contents_on_destroy = true
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.heygears.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=healthcare_fhir_store_notification_config&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Healthcare Fhir Store Notification Config


```hcl
resource "google_healthcare_fhir_store" "default" {
name = "example-fhir-store"
dataset = google_healthcare_dataset.dataset.id
version = "R4"

enable_update_create = false
disable_referential_integrity = false
disable_resource_versioning = false
enable_history_import = false

labels = {
label1 = "labelvalue1"
}

notification_configs {
pubsub_topic = "${google_pubsub_topic.topic.id}"
send_full_resource = true
}
}

resource "google_pubsub_topic" "topic" {
name = "fhir-notifications"
}

resource "google_healthcare_dataset" "dataset" {
name = "example-dataset"
location = "us-central1"
}
```

## Argument Reference

Expand Down Expand Up @@ -206,6 +244,11 @@ The following arguments are supported:
the order of dozens of seconds) is expected before the results show up in the streaming destination.
Structure is [documented below](#nested_stream_configs).

* `notification_configs` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
A list of notifcation configs that configure the notification for every resource mutation in this FHIR store.
Structure is [documented below](#nested_notification_configs).


<a name="nested_notification_config"></a>The `notification_config` block supports:

Expand Down Expand Up @@ -267,6 +310,25 @@ The following arguments are supported:
concept.concept but not concept.concept.concept. If not specified or set to 0, the server will use the default
value 2. The maximum depth allowed is 5.

<a name="nested_notification_configs"></a>The `notification_configs` block supports:

* `pubsub_topic` -
(Required)
The Cloud Pub/Sub topic that notifications of changes are published on. Supplied by the client.
PubsubMessage.Data will contain the resource name. PubsubMessage.MessageId is the ID of this message.
It is guaranteed to be unique within the topic. PubsubMessage.PublishTime is the time at which the message
was published. Notifications are only sent if the topic is non-empty. Topic names must be scoped to a
project. service-PROJECT_NUMBER@gcp-sa-healthcare.iam.gserviceaccount.com must have publisher permissions on the given
Cloud Pub/Sub topic. Not having adequate permissions will cause the calls that send notifications to fail.

* `send_full_resource` -
(Optional)
Whether to send full FHIR resource to this Pub/Sub topic for Create and Update operation.
Note that setting this to true does not guarantee that all resources will be sent in the format of
full FHIR resource. When a resource change is too large or during heavy traffic, only the resource name will be
sent. Clients should always check the "payloadType" label from a Pub/Sub message to determine whether
it needs to fetch the full resource as a separate operation.

## Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:
Expand Down