Skip to content
New issue

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

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

Already on GitHub? # to your account

error returned when list elements contain different fields #5

Closed
chkp-amirtal opened this issue Dec 8, 2021 · 1 comment
Closed

Comments

@chkp-amirtal
Copy link

example case:

module "deepmerge" {
  source  = "Invicton-Labs/deepmerge/null"
  version = "0.1.4"

  maps = [
    yamldecode(<<YAML
top:
  - name: NAME_1
    param: value1
    param2: 
      test: test
  - name: NAME_2
    param: value2
  - name: NAME_3
    param: value3
  - name: NAME_4
    param: value4
YAML
    ),
    {},
  ]
}

resource "null_resource" "test" {
  triggers = {
    a = yamlencode(module.deepmerge.merged)
  }
}

running plan return an error:

❯ terraform plan

Error: Invalid function argument

  on .terraform/modules/deepmerge/depth.tf line 43, in locals:
  43:           for key in keys(item["value"]) :
    |----------------
    | item["value"] is tuple with 4 elements

Invalid value for "inputMap" parameter: must have map or object type.


Error: Invalid function argument

  on .terraform/modules/deepmerge/depth.tf line 55, in locals:
  55:           for key in keys(item["value"]) :
    |----------------
    | item["value"] is tuple with 4 elements

Invalid value for "inputMap" parameter: must have map or object type.

to correct the error is is required to match all missing fields where needed, i.e.:

module "deepmerge" {
  source  = "Invicton-Labs/deepmerge/null"
  version = "0.1.4"

  maps = [
    yamldecode(<<YAML
top:
  - name: NAME_1
    param: value1
    param2: 
      test: test
  - name: NAME_2
    param: value2
    param2: {}
  - name: NAME_3
    param: value3
    param2: {}
  - name: NAME_4
    param: value4
    param2: {}
YAML
    ),
    {},
  ]
}

running plan will return correct results.
but this yaml might not always be usable by the backend system.
different items may require or support a different set of fields.

@KyleKotowick
Copy link
Contributor

Fixed in v0.1.6.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants