terraform-google-modules / terraform-google-cloud-storage

Creates one or more Cloud Storage buckets and assigns basic permissions on them to arbitrary users
https://registry.terraform.io/modules/terraform-google-modules/cloud-storage/google
Apache License 2.0
169 stars 558 forks source link

lookup default value for soft delete policy results in Error #324

Closed vdcadena553 closed 2 months ago

vdcadena553 commented 4 months ago

TL;DR

On a multi-bucket configuration, adding a soft_delete_policy configuration block like so:

soft_delete_policy = { "bucket1" = { // Disable protection on this bucket retention_duration_seconds = 0 } "bucket2" = { // Increase protection to the max value (90 days) retention_duration_seconds = 7776000 } } ; results in the following error:

│ Error: Invalid function argument │ │ on .terraform/modules/gcs.cloud_storage/main.tf line 160, in resource "google_storage_bucket" "buckets": │ 160: for_each = [lookup(var.soft_delete_policy, each.value, {})] │ ├──────────────── │ │ while calling lookup(inputMap, key, default...) │ │ Invalid value for "default" parameter: the default value must have the same │ type as the map elements.

Expected behavior

The module should allow to create a soft_delete block for a multibucket configuration without issues.

There is a PR opened to solve this https://github.com/terraform-google-modules/terraform-google-cloud-storage/pull/318

Observed behavior

The buckets should have the correct soft_delete retention time when deployed

Terraform Configuration

module "db_storage_buckets" {
  source     = "terraform-google-modules/cloud-storage/google"
  project_id =  "projectid"
  version    = "~>6.0"
  prefix     = "es-leg-uat"
  names      = ["backups", "tranlogs", "worm-backups", "worm-tranlogs"]
  location   = "US"

  soft_delete_policy = {
    "backups" = {
      retention_time_in_seconds = 0
    },
    "worm-tranlogs" = {
      retention_time_in_seconds = 0
    },
    "worm-backups" = {
      retention_time_in_seconds = 0
    },
    "tranlogs" ={
      retention_time_in_seconds = 0
    }
  }
}

Terraform Version

1.8.5

Additional information

No response

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days