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
170 stars 559 forks source link

soft_delete_policy argument error #345

Closed kimllee closed 1 month ago

kimllee commented 1 month ago

TL;DR

Hello,

I can't use the soft_delete_policy argument. Terraform v1.9.0 Module version 6.1.0

I have also tried using a variable with a default value + a real value.

Am I missing something please ?

Thank you.

Expected behavior

module "gcs_buckets" {
  source                   = "terraform-google-modules/cloud-storage/google"
  version                  = "~> 6.1"
  project_id               = var.project_name
  public_access_prevention = "ENFORCED"
  names                    = ["<BUCKET>"]
  set_admin_roles          = true
  #soft_delete_policy       = var.soft_delete_policy
  soft_delete_policy = {
    retention_duration_seconds = 0
  }
  versioning = {
    "enabled" = false
  }
}

Observed behavior

No response

Terraform Configuration

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

Terraform Version

v1.9.0

Additional information

image

kimllee commented 1 month ago

It's working using the submodule simple_bucket. The attribute soft_delete_policy looks for an object as entry in the submodule whereas it requires a map for the main module.