Skip to content

Commit d783b59

Browse files
feat: adding cmek settings in log bucket (#191)
1 parent fd276c3 commit d783b59

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

examples/logbucket/project/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module "log_export_same_proj" {
5757
module "dest_same_proj" {
5858
source = "../../..//modules/logbucket"
5959
project_id = var.project_destination_logbkt_id
60-
name = "logbucket_from_same_project_${random_string.suffix.result}"
60+
name = "logbucket_from_same_projct_${random_string.suffix.result}"
6161
location = "global"
6262
enable_analytics = true
6363
linked_dataset_id = "log_analytics_dataset_same"

modules/logbucket/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module "destination" {
3939
|------|-------------|------|---------|:--------:|
4040
| enable\_analytics | (Optional) Whether or not Log Analytics is enabled. A Log bucket with Log Analytics enabled can be queried in the Log Analytics page using SQL queries. Cannot be disabled once enabled. | `bool` | `false` | no |
4141
| grant\_write\_permission\_on\_bkt | (Optional) Indicates whether the module is responsible for granting write permission on the logbucket. This permission will be given by default, but if the user wants, this module can skip this step. This is the case when the sink route logs to a log bucket in the same Cloud project, no new service account will be created and this module will need to bypass granting permissions. | `bool` | `true` | no |
42+
| kms\_key\_name | To enable CMEK for a project logging bucket, set this field to a valid name. The associated service account requires cloudkms.cryptoKeyEncrypterDecrypter roles assigned for the key.The kms\_key\_name should be of the format projects/{project ID}/locations/{region}/keyRings/{keyring name}/cryptoKeys/{key name} | `string` | `null` | no |
4243
| linked\_dataset\_description | A use-friendly description of the linked BigQuery dataset. The maximum length of the description is 8000 characters. | `string` | `null` | no |
4344
| linked\_dataset\_id | The ID of the linked BigQuery dataset. A valid link dataset ID must only have alphanumeric characters and underscores within it and have up to 100 characters. | `string` | `null` | no |
4445
| location | The location of the log bucket. | `string` | `"global"` | no |

modules/logbucket/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ resource "google_logging_project_bucket_config" "bucket" {
4040
enable_analytics = var.enable_analytics
4141
bucket_id = var.name
4242
locked = var.locked
43+
dynamic "cmek_settings" {
44+
for_each = var.kms_key_name == null ? [] : [var.kms_key_name]
45+
content {
46+
kms_key_name = var.kms_key_name
47+
}
48+
}
4349
}
4450

4551
#-------------------------#

modules/logbucket/metadata.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ spec:
107107
type: number
108108
default: 30
109109
required: false
110+
- name: kms_key_name
111+
description: To enable CMEK for a project logging bucket, set this field to a valid name. The associated service account requires cloudkms.cryptoKeyEncrypterDecrypter roles assigned for the key.
112+
type: string
113+
required: false
110114
outputs:
111115
- name: console_link
112116
description: The console link to the destination log buckets

modules/logbucket/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@ variable "locked" {
7070
default = null
7171
type = bool
7272
}
73+
74+
variable "kms_key_name" {
75+
description = "To enable CMEK for a project logging bucket, set this field to a valid name. The associated service account requires cloudkms.cryptoKeyEncrypterDecrypter roles assigned for the key.The kms_key_name should be of the format projects/{project ID}/locations/{region}/keyRings/{keyring name}/cryptoKeys/{key name} "
76+
type = string
77+
default = null
78+
}
79+
80+

0 commit comments

Comments
 (0)