diff --git a/.changelog/6471.txt b/.changelog/6471.txt new file mode 100644 index 00000000000..d50c996ab84 --- /dev/null +++ b/.changelog/6471.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +healthcare: added `notification_configs ` field to `google_healthcare_fhir_store` resource +``` diff --git a/google/resource_healthcare_fhir_store_generated_test.go b/google/resource_healthcare_fhir_store_generated_test.go index 6dab15d67e7..844879b4edc 100644 --- a/google/resource_healthcare_fhir_store_generated_test.go +++ b/google/resource_healthcare_fhir_store_generated_test.go @@ -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 { diff --git a/website/docs/r/healthcare_fhir_store.html.markdown b/website/docs/r/healthcare_fhir_store.html.markdown index fb4ece42e3c..b67dd308bf1 100644 --- a/website/docs/r/healthcare_fhir_store.html.markdown +++ b/website/docs/r/healthcare_fhir_store.html.markdown @@ -118,6 +118,44 @@ resource "google_bigquery_dataset" "bq_dataset" { delete_contents_on_destroy = true } ``` +
+## 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 @@ -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). + The `notification_config` block supports: @@ -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. +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: