-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for CMEK datasets to terraform. (#10978)
- Loading branch information
1 parent
def52fe
commit 70941b6
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
mmv1/templates/terraform/examples/healthcare_dataset_cmek.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
data "google_project" "project" {} | ||
|
||
resource "google_healthcare_dataset" "default" { | ||
name = "<%= ctx[:vars]['dataset_name'] %>" | ||
location = "us-central1" | ||
time_zone = "UTC" | ||
|
||
encryption_spec { | ||
kms_key_name = google_kms_crypto_key.crypto_key.id | ||
} | ||
|
||
depends_on = [ | ||
google_kms_crypto_key_iam_binding.healthcare_cmek_keyuser | ||
] | ||
} | ||
|
||
resource "google_kms_crypto_key" "crypto_key" { | ||
name = "<%= ctx[:vars]['key_name'] %>" | ||
key_ring = google_kms_key_ring.key_ring.id | ||
purpose = "ENCRYPT_DECRYPT" | ||
} | ||
|
||
resource "google_kms_key_ring" "key_ring" { | ||
name = "<%= ctx[:vars]['keyring_name'] %>" | ||
location = "us-central1" | ||
} | ||
|
||
resource "google_kms_crypto_key_iam_binding" "healthcare_cmek_keyuser" { | ||
crypto_key_id = google_kms_crypto_key.crypto_key.id | ||
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" | ||
members = [ | ||
"serviceAccount:service-${data.google_project.project.number}@gcp-sa-healthcare.iam.gserviceaccount.com", | ||
] | ||
} | ||
|
||
|