feat(logging-bucket): support locked parameter for project parent types (#3650)
* feat(logging-bucket): support locked parameter for project parent types - Add locked parameter to project bucket resources with default value of false. * fixed the linting error, added the validation for project level bucket only and removed the nullable constraint
This commit is contained in:
@@ -118,17 +118,18 @@ module "bucket" {
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [name](variables.tf#L61) | Name of the logging bucket. | <code>string</code> | ✓ | |
|
||||
| [parent](variables.tf#L66) | ID of the parent resource containing the bucket in the format 'project_id' 'folders/folder_id', 'organizations/organization_id' or 'billing_account_id'. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L71) | Name of the logging bucket. | <code>string</code> | ✓ | |
|
||||
| [parent](variables.tf#L76) | ID of the parent resource containing the bucket in the format 'project_id' 'folders/folder_id', 'organizations/organization_id' or 'billing_account_id'. | <code>string</code> | ✓ | |
|
||||
| [context](variables.tf#L17) | Context-specific interpolations. | <code title="object({ custom_roles = optional(map(string), {}) folder_ids = optional(map(string), {}) iam_principals = optional(map(string), {}) kms_keys = optional(map(string), {}) locations = optional(map(string), {}) project_ids = optional(map(string), {}) tag_values = optional(map(string), {}) })">object({…})</code> | | <code>{}</code> |
|
||||
| [description](variables.tf#L32) | Human-readable description for the logging bucket. | <code>string</code> | | <code>null</code> |
|
||||
| [kms_key_name](variables.tf#L38) | 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. | <code>string</code> | | <code>null</code> |
|
||||
| [location](variables.tf#L44) | Location of the bucket. | <code>string</code> | | <code>"global"</code> |
|
||||
| [log_analytics](variables.tf#L50) | Enable and configure Analytics Log. | <code title="object({ enable = optional(bool, false) dataset_link_id = optional(string) description = optional(string, "Log Analytics Dataset") })">object({…})</code> | | <code>{}</code> |
|
||||
| [parent_type](variables.tf#L74) | Parent object type for the bucket (project, folder, organization, billing_account). | <code>string</code> | | <code>"project"</code> |
|
||||
| [retention](variables.tf#L81) | Retention time in days for the logging bucket. | <code>number</code> | | <code>30</code> |
|
||||
| [tag_bindings](variables.tf#L87) | Tag bindings for this bucket, in key => tag value id format. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [views](variables.tf#L94) | Log views for this bucket. | <code title="map(object({ filter = string location = optional(string) description = optional(string) iam = optional(map(list(string)), {}) iam_bindings = optional(map(object({ members = list(string) condition = optional(object({ expression = string title = string description = optional(string) })) })), {}) iam_bindings_additive = optional(map(object({ member = string role = string condition = optional(object({ expression = string title = string description = optional(string) })) })), {}) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [locked](variables.tf#L50) | Whether the bucket is locked. Locked buckets may only be deleted if they are empty. This can only be set for project-level buckets. | <code>bool</code> | | <code>null</code> |
|
||||
| [log_analytics](variables.tf#L60) | Enable and configure Analytics Log. | <code title="object({ enable = optional(bool, false) dataset_link_id = optional(string) description = optional(string, "Log Analytics Dataset") })">object({…})</code> | | <code>{}</code> |
|
||||
| [parent_type](variables.tf#L84) | Parent object type for the bucket (project, folder, organization, billing_account). | <code>string</code> | | <code>"project"</code> |
|
||||
| [retention](variables.tf#L91) | Retention time in days for the logging bucket. | <code>number</code> | | <code>30</code> |
|
||||
| [tag_bindings](variables.tf#L97) | Tag bindings for this bucket, in key => tag value id format. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [views](variables.tf#L104) | Log views for this bucket. | <code title="map(object({ filter = string location = optional(string) description = optional(string) iam = optional(map(list(string)), {}) iam_bindings = optional(map(object({ members = list(string) condition = optional(object({ expression = string title = string description = optional(string) })) })), {}) iam_bindings_additive = optional(map(object({ member = string role = string condition = optional(object({ expression = string title = string description = optional(string) })) })), {}) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ resource "google_logging_project_bucket_config" "bucket" {
|
||||
bucket_id = var.name
|
||||
description = var.description
|
||||
enable_analytics = var.log_analytics.enable
|
||||
locked = var.locked
|
||||
dynamic "cmek_settings" {
|
||||
for_each = var.kms_key_name == null ? [] : [""]
|
||||
content {
|
||||
|
||||
@@ -47,6 +47,16 @@ variable "location" {
|
||||
default = "global"
|
||||
}
|
||||
|
||||
variable "locked" {
|
||||
description = "Whether the bucket is locked. Locked buckets may only be deleted if they are empty. This can only be set for project-level buckets."
|
||||
type = bool
|
||||
default = null
|
||||
validation {
|
||||
condition = var.parent_type == "project" || var.locked == null
|
||||
error_message = "The 'locked' attribute can only be set for project-level buckets."
|
||||
}
|
||||
}
|
||||
|
||||
variable "log_analytics" {
|
||||
description = "Enable and configure Analytics Log."
|
||||
type = object({
|
||||
|
||||
Reference in New Issue
Block a user