-
Notifications
You must be signed in to change notification settings - Fork 32
Add additional encryption options #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,9 @@ | |
|
||
|
||
resource "google_pubsub_topic" "dataflow_deadletter_pubsub_topic" { | ||
project = var.project | ||
name = local.dataflow_output_deadletter_topic_name | ||
project = var.project | ||
name = local.dataflow_output_deadletter_topic_name | ||
kms_key_name = var.pubsub_kms_key_name | ||
} | ||
|
||
resource "google_pubsub_subscription" "dataflow_deadletter_pubsub_sub" { | ||
|
@@ -37,6 +38,12 @@ resource "google_storage_bucket" "dataflow_job_temp_bucket" { | |
name = local.dataflow_temporary_gcs_bucket_name | ||
location = var.region | ||
storage_class = "REGIONAL" | ||
dynamic "encryption" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see the intent behind this dynamic block. However it's not easy to read at all. Is there another better way to apply a conditional here? Maybe two bucket resources with conditional/count, one encrypted, the other is not enccypted. Also, what is driving this requirement given this is a temporary bucket? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There could be organization policy applied that you are not able to create any buckets despite of their content without CMEK for example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx for clarifying what's driving this PR. Org policies requiring use of CMEK for other services (GCS, PubSub or Dataflow) makes sense. |
||
for_each = (var.gcs_kms_key_name == "") ? [] : [1] | ||
content { | ||
default_kms_key_name = var.gcs_kms_key_name | ||
} | ||
} | ||
} | ||
|
||
resource "google_storage_bucket_object" "dataflow_job_temp_object" { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,3 +196,23 @@ variable "use_externally_managed_dataflow_sa" { | |
default = false | ||
description = "(Optional) Determines if the worker service account provided by `dataflow_worker_service_account` variable should be created by this module (default) or is managed outside of the module. In the latter case, user is expected to apply and manage the service account IAM permissions over external resources (e.g. Cloud KMS key or Secret version) before running this module." | ||
} | ||
|
||
variable "pubsub_kms_key_name" { | ||
type = string | ||
description = "(Optional) The resource name of the Cloud KMS CryptoKey to be used to protect access to messages published on created topics. Your project's PubSub service account (`service-{{PROJECT_NUMBER}}@gcp-sa-pubsub.iam.gserviceaccount.com`) must have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature. The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`." | ||
default = "" | ||
validation { | ||
condition = can(regex("^projects\\/[^\\n\\r\\/]+\\/locations\\/[^\\n\\r\\/]+\\/keyRings\\/[^\\n\\r\\/]+\\/cryptoKeys\\/[^\\n\\r\\/]+$", var.pubsub_kms_key_name)) || var.pubsub_kms_key_name == "" | ||
error_message = "Pub/Sub KMS key name must match: '^projects\\/[^\\n\\r\\/]+\\/locations\\/[^\\n\\r\\/]+\\/keyRings\\/[^\\n\\r\\/]+\\/cryptoKeys\\/[^\\n\\r\\/]+$' pattern." | ||
} | ||
} | ||
|
||
variable "gcs_kms_key_name" { | ||
type = string | ||
description = "(Optional) The `id` of a Cloud KMS key that will be used to encrypt objects inserted into temporary bucket. User is responsible for permissions to this key for Cloud Storage Service Account." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be helpful to document the permissions required in the README, even if they are not managed by the module. Same for KMS key for PubSub topic. |
||
default = "" | ||
validation { | ||
condition = can(regex("^projects\\/[^\\n\\r\\/]+\\/locations\\/[^\\n\\r\\/]+\\/keyRings\\/[^\\n\\r\\/]+\\/cryptoKeys\\/[^\\n\\r\\/]+$", var.gcs_kms_key_name)) || var.gcs_kms_key_name == "" | ||
error_message = "Cloud Storage KMS key name must match: '^projects\\/[^\\n\\r\\/]+\\/locations\\/[^\\n\\r\\/]+\\/keyRings\\/[^\\n\\r\\/]+\\/cryptoKeys\\/[^\\n\\r\\/]+$' pattern." | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will
kms_key_name
be ignored if user doesn't provide this input?