diff --git a/main.tf b/main.tf index e8695e3..c9047c8 100644 --- a/main.tf +++ b/main.tf @@ -8,11 +8,12 @@ locals { lifecycle_expiration_days = null } default_buckets = { - loki = local.default_parameters - thanos = local.default_parameters - velero = local.default_parameters + loki = merge(local.default_parameters, {bucket_name_override = "${var.cluster_name}-logs"}) + thanos = merge(local.default_parameters, {bucket_name_override = "batcave-${var.cluster_name}-thanos"}) + velero = merge(local.default_parameters, {bucket_name_override = "${var.cluster_name}-batcave-velero-storage"}) } - all_buckets = merge(local.default_buckets, var.bucket_specs) + all_bucket_names = toset(concat(keys(local.default_buckets), keys(var.bucket_specs))) + all_buckets = {for name in local.all_bucket_names : name => merge(try(local.default_buckets[name], {}), try(var.bucket_specs[name], {}))} } module "bucket" { diff --git a/variables.tf b/variables.tf index 268d5be..63be516 100644 --- a/variables.tf +++ b/variables.tf @@ -1,12 +1,14 @@ variable "bucket_specs" { - type = map(object({ - bucket_name_override = optional(string, "") - force_destroy = optional(bool, false) - tags = optional(map(any), {}) - s3_bucket_kms_key_id = optional(string, null) - sse_algorithm = optional(string, "aws:kms") - lifecycle_expiration_days = optional(number, null) - })) + type = map(any) + ## Cannot configure strict typing or local default will be blown away by implicit object defaults + #type = map(object({ + # bucket_name_override = optional(string) + # force_destroy = optional(bool) + # tags = optional(map(any)) + # s3_bucket_kms_key_id = optional(string) + # sse_algorithm = optional(string) + # lifecycle_expiration_days = optional(number) + #})) default = {} }