Skip to content

Commit

Permalink
Add new resource for creating Whistle Mapping, Reconciliation and Bac…
Browse files Browse the repository at this point in the history
…kfill Pipeline Jobs for Healthcare Data Engine (#11677) (#802)

[upstream:1902bacf8e9c72befb6dfb29945bc5effb7355ab]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Sep 19, 2024
1 parent b541d4f commit 115e6bb
Show file tree
Hide file tree
Showing 16 changed files with 596 additions and 0 deletions.
15 changes: 15 additions & 0 deletions healthcare_pipeline_job_backfill/backing_file.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file has some scaffolding to make sure that names are unique and that
# a region and zone are selected when you try to create your Terraform resources.

locals {
name_suffix = "${random_pet.suffix.id}"
}

resource "random_pet" "suffix" {
length = 2
}

provider "google" {
region = "us-central1"
zone = "us-central1-c"
}
13 changes: 13 additions & 0 deletions healthcare_pipeline_job_backfill/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "google_healthcare_pipeline_job" "example-pipeline" {
name = "example_backfill_pipeline-${local.name_suffix}"
location = "us-central1"
dataset = google_healthcare_dataset.dataset.id
backfill_pipeline_job {
mapping_pipeline_job = "${google_healthcare_dataset.dataset.id}/pipelinejobs/example_mapping_pipeline-${local.name_suffix}"
}
}

resource "google_healthcare_dataset" "dataset" {
name = "example_dataset-${local.name_suffix}"
location = "us-central1"
}
7 changes: 7 additions & 0 deletions healthcare_pipeline_job_backfill/motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
===

These examples use real resources that will be billed to the
Google Cloud Platform project you use - so make sure that you
run "terraform destroy" before quitting!

===
79 changes: 79 additions & 0 deletions healthcare_pipeline_job_backfill/tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Healthcare Pipeline Job Backfill - Terraform

## Setup

<walkthrough-author name="[email protected]" analyticsId="UA-125550242-1" tutorialName="healthcare_pipeline_job_backfill" repositoryUrl="https://github.com/terraform-google-modules/docs-examples"></walkthrough-author>

Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform.

<walkthrough-project-billing-setup></walkthrough-project-billing-setup>

Terraform provisions real GCP resources, so anything you create in this session will be billed against this project.

## Terraforming!

Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command
to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up
the project name from the environment variable.

```bash
export GOOGLE_CLOUD_PROJECT={{project-id}}
```

After that, let's get Terraform started. Run the following to pull in the providers.

```bash
terraform init
```

With the providers downloaded and a project set, you're ready to use Terraform. Go ahead!

```bash
terraform apply
```

Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan.

```bash
yes
```


## Post-Apply

### Editing your config

Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed.

```bash
terraform plan
```

So let's make a change! Try editing a number, or appending a value to the name in the editor. Then,
run a 'plan' again.

```bash
terraform plan
```

Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes
at the 'yes' prompt.

```bash
terraform apply
```

```bash
yes
```

## Cleanup

Run the following to remove the resources Terraform provisioned:

```bash
terraform destroy
```
```bash
yes
```
15 changes: 15 additions & 0 deletions healthcare_pipeline_job_mapping_recon_dest/backing_file.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file has some scaffolding to make sure that names are unique and that
# a region and zone are selected when you try to create your Terraform resources.

locals {
name_suffix = "${random_pet.suffix.id}"
}

resource "random_pet" "suffix" {
length = 2
}

provider "google" {
region = "us-central1"
zone = "us-central1-c"
}
81 changes: 81 additions & 0 deletions healthcare_pipeline_job_mapping_recon_dest/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
resource "google_healthcare_pipeline_job" "recon" {
name = "example_recon_pipeline_job-${local.name_suffix}"
location = "us-central1"
dataset = google_healthcare_dataset.dataset.id
disable_lineage = true
reconciliation_pipeline_job {
merge_config {
description = "sample description for reconciliation rules"
whistle_config_source {
uri = "gs://${google_storage_bucket.bucket.name}/${google_storage_bucket_object.merge_file.name}"
import_uri_prefix = "gs://${google_storage_bucket.bucket.name}"
}
}
matching_uri_prefix = "gs://${google_storage_bucket.bucket.name}"
fhir_store_destination = "${google_healthcare_dataset.dataset.id}/fhirStores/${google_healthcare_fhir_store.dest_fhirstore.name}"
}
}

resource "google_healthcare_pipeline_job" "example-mapping-pipeline" {
depends_on = [google_healthcare_pipeline_job.recon]
name = "example_mapping_pipeline_job-${local.name_suffix}"
location = "us-central1"
dataset = google_healthcare_dataset.dataset.id
disable_lineage = true
labels = {
example_label_key = "example_label_value"
}
mapping_pipeline_job {
mapping_config {
whistle_config_source {
uri = "gs://${google_storage_bucket.bucket.name}/${google_storage_bucket_object.mapping_file.name}"
import_uri_prefix = "gs://${google_storage_bucket.bucket.name}"
}
description = "example description for mapping configuration"
}
fhir_streaming_source {
fhir_store = "${google_healthcare_dataset.dataset.id}/fhirStores/${google_healthcare_fhir_store.source_fhirstore.name}"
description = "example description for streaming fhirstore"
}
reconciliation_destination = true
}
}

resource "google_healthcare_dataset" "dataset" {
name = "example_dataset-${local.name_suffix}"
location = "us-central1"
}

resource "google_healthcare_fhir_store" "source_fhirstore" {
name = "source_fhir_store-${local.name_suffix}"
dataset = google_healthcare_dataset.dataset.id
version = "R4"
enable_update_create = true
disable_referential_integrity = true
}

resource "google_healthcare_fhir_store" "dest_fhirstore" {
name = "dest_fhir_store-${local.name_suffix}"
dataset = google_healthcare_dataset.dataset.id
version = "R4"
enable_update_create = true
disable_referential_integrity = true
}

resource "google_storage_bucket" "bucket" {
name = "example_bucket_name-${local.name_suffix}"
location = "us-central1"
uniform_bucket_level_access = true
}

resource "google_storage_bucket_object" "mapping_file" {
name = "mapping.wstl"
content = " "
bucket = google_storage_bucket.bucket.name
}

resource "google_storage_bucket_object" "merge_file" {
name = "merge.wstl"
content = " "
bucket = google_storage_bucket.bucket.name
}
7 changes: 7 additions & 0 deletions healthcare_pipeline_job_mapping_recon_dest/motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
===

These examples use real resources that will be billed to the
Google Cloud Platform project you use - so make sure that you
run "terraform destroy" before quitting!

===
79 changes: 79 additions & 0 deletions healthcare_pipeline_job_mapping_recon_dest/tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Healthcare Pipeline Job Mapping Recon Dest - Terraform

## Setup

<walkthrough-author name="[email protected]" analyticsId="UA-125550242-1" tutorialName="healthcare_pipeline_job_mapping_recon_dest" repositoryUrl="https://github.com/terraform-google-modules/docs-examples"></walkthrough-author>

Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform.

<walkthrough-project-billing-setup></walkthrough-project-billing-setup>

Terraform provisions real GCP resources, so anything you create in this session will be billed against this project.

## Terraforming!

Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command
to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up
the project name from the environment variable.

```bash
export GOOGLE_CLOUD_PROJECT={{project-id}}
```

After that, let's get Terraform started. Run the following to pull in the providers.

```bash
terraform init
```

With the providers downloaded and a project set, you're ready to use Terraform. Go ahead!

```bash
terraform apply
```

Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan.

```bash
yes
```


## Post-Apply

### Editing your config

Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed.

```bash
terraform plan
```

So let's make a change! Try editing a number, or appending a value to the name in the editor. Then,
run a 'plan' again.

```bash
terraform plan
```

Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes
at the 'yes' prompt.

```bash
terraform apply
```

```bash
yes
```

## Cleanup

Run the following to remove the resources Terraform provisioned:

```bash
terraform destroy
```
```bash
yes
```
15 changes: 15 additions & 0 deletions healthcare_pipeline_job_reconciliation/backing_file.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file has some scaffolding to make sure that names are unique and that
# a region and zone are selected when you try to create your Terraform resources.

locals {
name_suffix = "${random_pet.suffix.id}"
}

resource "random_pet" "suffix" {
length = 2
}

provider "google" {
region = "us-central1"
zone = "us-central1-c"
}
42 changes: 42 additions & 0 deletions healthcare_pipeline_job_reconciliation/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
resource "google_healthcare_pipeline_job" "example-pipeline" {
name = "example_pipeline_job-${local.name_suffix}"
location = "us-central1"
dataset = google_healthcare_dataset.dataset.id
disable_lineage = true
reconciliation_pipeline_job {
merge_config {
description = "sample description for reconciliation rules"
whistle_config_source {
uri = "gs://${google_storage_bucket.bucket.name}/${google_storage_bucket_object.merge_file.name}"
import_uri_prefix = "gs://${google_storage_bucket.bucket.name}"
}
}
matching_uri_prefix = "gs://${google_storage_bucket.bucket.name}"
fhir_store_destination = "${google_healthcare_dataset.dataset.id}/fhirStores/${google_healthcare_fhir_store.fhirstore.name}"
}
}

resource "google_healthcare_dataset" "dataset" {
name = "example_dataset-${local.name_suffix}"
location = "us-central1"
}

resource "google_healthcare_fhir_store" "fhirstore" {
name = "fhir_store-${local.name_suffix}"
dataset = google_healthcare_dataset.dataset.id
version = "R4"
enable_update_create = true
disable_referential_integrity = true
}

resource "google_storage_bucket" "bucket" {
name = "example_bucket_name-${local.name_suffix}"
location = "us-central1"
uniform_bucket_level_access = true
}

resource "google_storage_bucket_object" "merge_file" {
name = "merge.wstl"
content = " "
bucket = google_storage_bucket.bucket.name
}
7 changes: 7 additions & 0 deletions healthcare_pipeline_job_reconciliation/motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
===

These examples use real resources that will be billed to the
Google Cloud Platform project you use - so make sure that you
run "terraform destroy" before quitting!

===
Loading

0 comments on commit 115e6bb

Please sign in to comment.