0.12upgrade messing up with code logic and functionality

We are migrating our infrastructure to terraform 0.12 from 0.11. Using 0.12upgrade integrated tool for this. It is well documented and is doing it’s job well.

But on one of the layers, I faced a weird problem: 0.12upgrade tool during code migration did a huge mess with code logic and even functionality. I spent a bunch of time to investigate it, but no luck.

Here are some snippets of its changes:


Terrafortm v0.11 (original)

count = (local.logstash_node_count) * (data.terraform_remote_state.pki.outputs.ssm_agent_enabled ? 1 : 0 ) > 0 ? 1 : 0

Terrafortm v0.12.24 (Converted code)
local.logstash_node_count * data.terraform_remote_state.pki.outputs.ssm_agent_enabled ? 1 : 0 > 0 ? 1 : 0


Terrafortm v0.11 (original)
port = "${lookup(var.additional_context_based_tg[element(keys(var.additional_context_based_tg),count.index)], "port")}"

Terrafortm v0.12.24 (Converted code)
port = var.additional_context_based_tg[element(keys(var.additional_context_based_tg), count.index)]["port"]

Perhaps someone faced something similar or the same issue or knows the root cause of it to point me to the right direction to resolve it.