Syntax issues while upgrading from 11.14 to version 12

Here is my syntax that works just fine on 11.14:

security_groups = [ “${split(”,", var.webproxy_webpool_enabled ? join(",", local.test_webproxy_pool_sec_groups) : join(",", local.test_webproxy_sec_groups))}"]

After running terraform 0.12upgrade
Line is updated to look like so:
security_groups = split(
var.webproxy_webpool_enabled ? join(",", local.test_webproxy_pool_sec_groups) : join(",", local.test_webproxy_sec_groups),

Here is the error I am getting:
Error: Incorrect condition type

on line 24, in resource “aws_security_group” “test”:
24: var.haproxy_cloudpool_enabled ? join(",", local.test_webproxy_pool_sec_groups) : join(",", local.test_webproxy_sec_groups),
| var.webproxy_webpool_enabled is 1

The condition expression must be of type bool.

Hi @cptcrush,

It sounds like your webproxy_webpool_enabled variable is defined as a number rather than as a boolean. To fix it, you could redefine it as being a boolean value:

variable "webproxy_webpool_enabled" {
  type = bool

Then in module blocks that are calling this module, set the argument to true rather than to 1:

  webproxy_webpool_enabled = true

While you’re looking at this portion of code, it’s worth noting that this workaround of joining to a string and then splitting again in order to conditionally choose a list is no longer necessary in Terraform 0.12, so you could also simplify this expression:

  security_groups = var.webproxy_webpool_enabled ?
    local.test_webproxy_pool_sec_groups :