Skip to content
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

feat: adding cmek settings in log bucket #191

Merged
merged 7 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/logbucket/project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module "log_export_same_proj" {
module "dest_same_proj" {
source = "../../..//modules/logbucket"
project_id = var.project_destination_logbkt_id
name = "logbucket_from_same_project_${random_string.suffix.result}"
name = "logbucket_from_same_projct_${random_string.suffix.result}"
location = "global"
enable_analytics = true
linked_dataset_id = "log_analytics_dataset_same"
Expand Down
1 change: 1 addition & 0 deletions modules/logbucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module "destination" {
|------|-------------|------|---------|:--------:|
| 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 |
| 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 |
| 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 |
| linked\_dataset\_description | A use-friendly description of the linked BigQuery dataset. The maximum length of the description is 8000 characters. | `string` | `null` | no |
| 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 |
| location | The location of the log bucket. | `string` | `"global"` | no |
Expand Down
6 changes: 6 additions & 0 deletions modules/logbucket/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ resource "google_logging_project_bucket_config" "bucket" {
enable_analytics = var.enable_analytics
bucket_id = var.name
locked = var.locked
dynamic "cmek_settings" {
for_each = var.kms_key_name == null ? [] : [var.kms_key_name]
content {
kms_key_name = var.kms_key_name
}
}
}

#-------------------------#
Expand Down
4 changes: 4 additions & 0 deletions modules/logbucket/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ spec:
type: number
default: 30
required: false
- name: kms_key_name
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.
type: string
required: false
outputs:
- name: console_link
description: The console link to the destination log buckets
Expand Down
8 changes: 8 additions & 0 deletions modules/logbucket/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ variable "locked" {
default = null
type = bool
}

variable "kms_key_name" {
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} "
type = string
default = null
}