Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soft_delete_policy default value is incorrect #317

Closed
ryanfangk opened this issue May 17, 2024 · 1 comment
Closed

soft_delete_policy default value is incorrect #317

ryanfangk opened this issue May 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ryanfangk
Copy link

TL;DR

for_each = [lookup(var.soft_delete_policy, each.value, {})]

The default value of soft_delete_policy should be a string instead of an empty object, since it should be the same type as keys of the map

Expected behavior

No error should be thrown

Observed behavior

│ 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, {})]
│ ├────────────────
│ │ while calling lookup(inputMap, key, default...)

│ Invalid value for "default" parameter: the default value must have the same type as the map elements.

Terraform Configuration

Here is the tfvars value I am currently using
    soft_delete_policy = {
      "development-terraform" = { retention_duration_seconds = 604800 } # 7 days
      "production-terraform"  = { retention_duration_seconds = 604800 } # 7 days
    }

Terraform Version

Terraform v1.8.3
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v5.28.0
+ provider registry.terraform.io/hashicorp/google-beta v5.28.0
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/hashicorp/random v3.6.1
+ provider registry.terraform.io/hashicorp/time v0.11.1

Additional information

Should be an easy fix, just replace empty object {} with empty string ""

https://developer.hashicorp.com/terraform/language/functions/lookup

@ryanfangk ryanfangk added the bug Something isn't working label May 17, 2024
@luqic
Copy link

luqic commented Jun 19, 2024

Hello! I am facing the same issue, can I check how you managed to resolve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants