Is there a way AND/OR conditional operator in terraform?

后端 未结 4 1887
离开以前
离开以前 2020-12-29 07:27

Is there a way to use something like this in Terraform?

count = \"${var.I_am_true}\"&&\"${var.I_am_false}\"

4条回答
  •  Happy的楠姐
    2020-12-29 08:22

    There's no binary type defined in Terraform. But you can try to use simple math

    E.g.

    OR equivalent

     count = signum(${var.I_am_true} + ${var.I_am_false})
    

    AND equivalent

     count = ${var.I_am_true} * ${var.I_am_false}
    

    Both will work if I_am_true == 1 and I_am_false == 0.

    Didn't try both, though.

提交回复
热议问题