diff --git a/modules/gcs/README.md b/modules/gcs/README.md
index fdba89e60..627ce93a2 100644
--- a/modules/gcs/README.md
+++ b/modules/gcs/README.md
@@ -97,9 +97,9 @@ module "buckets" {
| *iam_roles* | IAM roles keyed by bucket name. | map(list(string)) | | {} |
| *labels* | Labels to be attached to all buckets. | map(string) | | {} |
| *location* | Bucket location. | string | | EU |
-| *logging* | Per-bucket logging. | map(object) | | {} |
+| *logging_config* | Per-bucket logging. | map(object({...})) | | {} |
| *prefix* | Prefix used to generate the bucket name. | string | | null |
-| *retention_policies* | Per-bucket retention policy. | map(object) | | {} |
+| *retention_policies* | Per-bucket retention policy. | map(object({...})) | | {} |
| *storage_class* | Bucket storage class. | string | | MULTI_REGIONAL |
| *versioning* | Optional map to set versioning keyed by name, defaults to false. | map(bool) | | {} |
diff --git a/modules/gcs/main.tf b/modules/gcs/main.tf
index 44feda5fb..92a84107d 100644
--- a/modules/gcs/main.tf
+++ b/modules/gcs/main.tf
@@ -36,9 +36,15 @@ locals {
? ""
: join("-", [var.prefix, lower(var.location), ""])
)
- kms_keys = { for name in var.names : name => lookup(var.encryption_keys, name, null) }
- retention_policy = { for name in var.names : name => lookup(var.retention_policies, name, null) }
- logging_config = { for name in var.names : name => lookup(var.logging_config, name, null) }
+ kms_keys = {
+ for name in var.names : name => lookup(var.encryption_keys, name, null)
+ }
+ retention_policy = {
+ for name in var.names : name => lookup(var.retention_policies, name, null)
+ }
+ logging_config = {
+ for name in var.names : name => lookup(var.logging_config, name, null)
+ }
}
resource "google_storage_bucket" "buckets" {
@@ -70,14 +76,14 @@ resource "google_storage_bucket" "buckets" {
for_each = local.retention_policy[each.key] == null ? [] : [""]
content {
retention_period = local.retention_policy[each.key]["retention_period"]
- is_locked = local.retention_policy[each.key]["is_locked"]
+ is_locked = local.retention_policy[each.key]["is_locked"]
}
}
dynamic logging {
for_each = local.logging_config[each.key] == null ? [] : [""]
content {
- log_bucket = local.logging_config[each.key]["log_bucket"]
+ log_bucket = local.logging_config[each.key]["log_bucket"]
log_object_prefix = local.logging_config[each.key]["log_object_prefix"]
}
}
diff --git a/modules/gcs/variables.tf b/modules/gcs/variables.tf
index 790381659..5ea231b20 100644
--- a/modules/gcs/variables.tf
+++ b/modules/gcs/variables.tf
@@ -87,17 +87,17 @@ variable "versioning" {
variable "retention_policies" {
description = "Per-bucket retention policy."
type = map(object({
- retention_period = number
- is_locked = bool
- }))
- default = {}
+ retention_period = number
+ is_locked = bool
+ }))
+ default = {}
}
variable "logging_config" {
description = "Per-bucket logging."
type = map(object({
- log_bucket = string
- log_object_prefix = string
- }))
- default = {}
+ log_bucket = string
+ log_object_prefix = string
+ }))
+ default = {}
}