Skip to content

Variable Type not working when specific #103

@schammah

Description

@schammah

Description

Unable to specify a defined type for the variable records, only works with any
Not sure how much it is a bug but if we want to define a better type it won't work.

  • ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [Required]: 2.10.2

  • Terraform version:

1.6.4
  • Provider version(s):
5.29.0

Reproduction Code [Required]

Steps to reproduce the behavior:

No Yes

Using a type of any like here works well
But when trying to define records like that:

    records = list(object({
      name    = string
      type    = string
      ttl     = optional(number, null)
      records = optional(list(string), null)
      alias = optional(object({
        name                   = string
        zone_id                = string
        evaluate_target_health = optional(bool, null)
      }), null)

fails due to the lookup being done with this code

Expected behavior

Terraform run should work when alias object is set to null, (meaning for this entry im using records)

Actual behavior

Fails with following error:


│ Error: Invalid function argument
│
│   on .terraform/modules/route53_records/modules/records/main.tf line 33, in resource "aws_route53_record" "this":
│   33:     for_each = length(keys(lookup(each.value, "alias", {}))) == 0 ? [] : [true]
│     ├────────────────
│     │ while calling keys(inputMap)
│     │ each.value is object with 5 attributes
│
│ Invalid value for "inputMap" parameter: argument must not be null.
╵

Additional context

Must add of course than using any for the variable type solve this but its always nicer to have your type specifically defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions