The Daily WTF
Ilsa‘s organization uses Terraform to handle provisioning their infrastructure. This mostly works fine for the organization, but one day it started deleting their load balancer off of AWS for no good reason.
Ilsa investigated, but wasn’t exactly sure about why that was happening. What she did find, however, was this particular ternary expression.
resource “aws_lb_listener” “this” { count = var.internal == true || var.provision == true ? length(var.listener) : 0 && var.internal == false || var.provision == true ? length(var.listener) : 0 … }
As mentioned yesterday, variable == true in a conditional expression is one of my pet peeves, though I suppose I don’t know HCL that well- it may be the case that there may be truthy values that are not true, so this might be necessary (or at least caused by bad choices elsewhere in the system).
In the end, I think this highlights the problem
To read the full article click on the 'post' link at the top.