From 317630cbeda0e892e1a4505e78e95f26e1eeaa2d Mon Sep 17 00:00:00 2001 From: j-mowery <98827382+j-mowery@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:30:12 -0500 Subject: [PATCH] BATIAI-1936 - Update Default Bucket Names (#6) * BATIAI-1936 - merge current default name as override * Fixing bucket prop merge * Apply suggestions from code review --------- Co-authored-by: Charles Bushong Co-authored-by: Charles Bushong --- main.tf | 9 +++++---- variables.tf | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) 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 = {} }