Skip to content

Commit 2a446aa

Browse files
Support healthcare fhir new notifications config (#6471) (#12646)
Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent 58d2906 commit 2a446aa

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

.changelog/6471.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
healthcare: added `notification_configs ` field to `google_healthcare_fhir_store` resource
3+
```

google/resource_healthcare_fhir_store_generated_test.go

+58
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,64 @@ resource "google_bigquery_dataset" "bq_dataset" {
151151
`, context)
152152
}
153153

154+
func TestAccHealthcareFhirStore_healthcareFhirStoreNotificationConfigExample(t *testing.T) {
155+
t.Parallel()
156+
157+
context := map[string]interface{}{
158+
"random_suffix": randString(t, 10),
159+
}
160+
161+
vcrTest(t, resource.TestCase{
162+
PreCheck: func() { testAccPreCheck(t) },
163+
Providers: testAccProviders,
164+
CheckDestroy: testAccCheckHealthcareFhirStoreDestroyProducer(t),
165+
Steps: []resource.TestStep{
166+
{
167+
Config: testAccHealthcareFhirStore_healthcareFhirStoreNotificationConfigExample(context),
168+
},
169+
{
170+
ResourceName: "google_healthcare_fhir_store.default",
171+
ImportState: true,
172+
ImportStateVerify: true,
173+
ImportStateVerifyIgnore: []string{"self_link", "dataset"},
174+
},
175+
},
176+
})
177+
}
178+
179+
func testAccHealthcareFhirStore_healthcareFhirStoreNotificationConfigExample(context map[string]interface{}) string {
180+
return Nprintf(`
181+
resource "google_healthcare_fhir_store" "default" {
182+
name = "tf-test-example-fhir-store%{random_suffix}"
183+
dataset = google_healthcare_dataset.dataset.id
184+
version = "R4"
185+
186+
enable_update_create = false
187+
disable_referential_integrity = false
188+
disable_resource_versioning = false
189+
enable_history_import = false
190+
191+
labels = {
192+
label1 = "labelvalue1"
193+
}
194+
195+
notification_configs {
196+
pubsub_topic = "${google_pubsub_topic.topic.id}"
197+
send_full_resource = true
198+
}
199+
}
200+
201+
resource "google_pubsub_topic" "topic" {
202+
name = "tf-test-fhir-notifications%{random_suffix}"
203+
}
204+
205+
resource "google_healthcare_dataset" "dataset" {
206+
name = "tf-test-example-dataset%{random_suffix}"
207+
location = "us-central1"
208+
}
209+
`, context)
210+
}
211+
154212
func testAccCheckHealthcareFhirStoreDestroyProducer(t *testing.T) func(s *terraform.State) error {
155213
return func(s *terraform.State) error {
156214
for name, rs := range s.RootModule().Resources {

website/docs/r/healthcare_fhir_store.html.markdown

+62
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,44 @@ resource "google_bigquery_dataset" "bq_dataset" {
118118
delete_contents_on_destroy = true
119119
}
120120
```
121+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
122+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.jpy.wang%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">
123+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
124+
</a>
125+
</div>
126+
## Example Usage - Healthcare Fhir Store Notification Config
127+
128+
129+
```hcl
130+
resource "google_healthcare_fhir_store" "default" {
131+
name = "example-fhir-store"
132+
dataset = google_healthcare_dataset.dataset.id
133+
version = "R4"
134+
135+
enable_update_create = false
136+
disable_referential_integrity = false
137+
disable_resource_versioning = false
138+
enable_history_import = false
139+
140+
labels = {
141+
label1 = "labelvalue1"
142+
}
143+
144+
notification_configs {
145+
pubsub_topic = "${google_pubsub_topic.topic.id}"
146+
send_full_resource = true
147+
}
148+
}
149+
150+
resource "google_pubsub_topic" "topic" {
151+
name = "fhir-notifications"
152+
}
153+
154+
resource "google_healthcare_dataset" "dataset" {
155+
name = "example-dataset"
156+
location = "us-central1"
157+
}
158+
```
121159

122160
## Argument Reference
123161

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

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

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

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

313+
<a name="nested_notification_configs"></a>The `notification_configs` block supports:
314+
315+
* `pubsub_topic` -
316+
(Required)
317+
The Cloud Pub/Sub topic that notifications of changes are published on. Supplied by the client.
318+
PubsubMessage.Data will contain the resource name. PubsubMessage.MessageId is the ID of this message.
319+
It is guaranteed to be unique within the topic. PubsubMessage.PublishTime is the time at which the message
320+
was published. Notifications are only sent if the topic is non-empty. Topic names must be scoped to a
321+
project. [email protected] must have publisher permissions on the given
322+
Cloud Pub/Sub topic. Not having adequate permissions will cause the calls that send notifications to fail.
323+
324+
* `send_full_resource` -
325+
(Optional)
326+
Whether to send full FHIR resource to this Pub/Sub topic for Create and Update operation.
327+
Note that setting this to true does not guarantee that all resources will be sent in the format of
328+
full FHIR resource. When a resource change is too large or during heavy traffic, only the resource name will be
329+
sent. Clients should always check the "payloadType" label from a Pub/Sub message to determine whether
330+
it needs to fetch the full resource as a separate operation.
331+
270332
## Attributes Reference
271333

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

0 commit comments

Comments
 (0)