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

terraform validaton fails #137

Closed
ntmggr opened this issue Dec 17, 2022 · 1 comment
Closed

terraform validaton fails #137

ntmggr opened this issue Dec 17, 2022 · 1 comment
Labels
invalid This doesn't seem right

Comments

@ntmggr
Copy link

ntmggr commented Dec 17, 2022

Using latest source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=0.25.0"

terraform --version                                                                                                                                                                     nikos
Terraform v1.3.6
on darwin_amd64
╷
│ Error: Invalid function argument
│ 
│   on .terraform/modules/label/variables.tf line 38, in variable "context":
│   38:     condition     = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"])
│     ├────────────────
│     │ while calling lookup(inputMap, key, default...)
│     │ var.context is a string
│ 
│ Invalid value for "inputMap" parameter: lookup() requires a map as the
│ first argument.
╵
╷
│ Error: Invalid function argument
│ 
│   on .terraform/modules/label/variables.tf line 43, in variable "context":
│   43:     condition     = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"])
│     ├────────────────
│     │ while calling lookup(inputMap, key, default...)
│     │ var.context is a string
│ 
│ Invalid value for "inputMap" parameter: lookup() requires a map as the
│ first argument.
╵


Validation failed: terraform/modules/label
╷
│ Error: Invalid function argument
│ 
│   on .terraform/modules/label/variables.tf line 38, in variable "context":
│   38:     condition     = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"])
│     ├────────────────
│     │ while calling lookup(inputMap, key, default...)
│     │ var.context is a string
│ 
│ Invalid value for "inputMap" parameter: lookup() requires a map as the
│ first argument.
╵
╷
│ Error: Invalid function argument
│ 
│   on .terraform/modules/label/variables.tf line 43, in variable "context":
│   43:     condition     = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"])
│     ├────────────────
│     │ while calling lookup(inputMap, key, default...)
│     │ var.context is a string
│ 
│ Invalid value for "inputMap" parameter: lookup() requires a map as the
│ first argument.```
@Nuru Nuru added the invalid This doesn't seem right label Aug 1, 2023
@Nuru
Copy link
Contributor

Nuru commented Aug 1, 2023

This happens if you set context = "some string value". context is defined as type = any because it has been around since before Terraform had types and we want it to be as compatible as possible with various Terraform versions. However, it actually is required to be an object, which you would get from the output of another null-label module. You can infer the full definition of the object from the default value:

default = {
enabled = true
namespace = null
tenant = null
environment = null
stage = null
name = null
delimiter = null
attributes = []
tags = {}
additional_tag_map = {}
regex_replace_chars = null
label_order = []
id_length_limit = null
label_key_case = null
label_value_case = null
descriptor_formats = {}
# Note: we have to use [] instead of null for unset lists due to
# https://github.com/hashicorp/terraform/issues/28137
# which was not fixed until Terraform 1.0.0,
# but we want the default to be all the labels in `label_order`
# and we want users to be able to prevent all tag generation
# by setting `labels_as_tags` to `[]`, so we need
# a different sentinel to indicate "default"
labels_as_tags = ["unset"]
}

Closing as invalid.

@Nuru Nuru closed this as completed Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants