Skip to content

Conditions on var.instances result in "error in function call" when var.instances is an empty map #404

@cmd-ntrf

Description

@cmd-ntrf

While no common use case, operator creating cluster via the MC-Hub interface have a tendency to remove all instances, resulting an empty map. This results in an error instead of the expected empty shell.

I think the conditions could adjusted to support the empty map use case.

Error: Error in function call

  on /magic_castle/openstack/variables.tf line 23, in variable "instances":
  23:     condition     = alltrue(concat([for key, values in var.instances: [contains(keys(values), "type"), contains(keys(values), "tags")]]...))
    ├────────────────
    │ while calling concat(seqs...)
    │ var.instances is object with no attributes

Call to function "concat" failed: at least one argument is required.

Error: Invalid function argument

  on /magic_castle/openstack/variables.tf line 27, in variable "instances":
  27:     condition = sum([for key, values in var.instances: contains(values["tags"], "proxy") ? values["count"] : 0]) < 2
    ├────────────────
    │ while calling sum(list)
    │ var.instances is object with no attributes

Invalid value for "list" parameter: cannot sum an empty list.

Error: Invalid function argument

  on /magic_castle/openstack/variables.tf line 31, in variable "instances":
  31:     condition = sum([for key, values in var.instances: contains(values["tags"], "login") ? 1 : 0]) < 2
    ├────────────────
    │ while calling sum(list)
    │ var.instances is object with no attributes

Invalid value for "list" parameter: cannot sum an empty list.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions