dynamic values causes huge diff without real changes after upgrade
lorenzosfarra opened this issue · 1 comments
lorenzosfarra commented
Hi,
I am currently in the process of updating the plugin version from 1.0 to 1.13.
I have also tried a "safer" jump, from 1.0 to 1.4, but with the same result.
Basically, before the migration, I had this syntax:
attribute {
name = "fake-name"
label = {
it-IT = "<label here>"
en-US = "<other label here>"
}
input_tip = {
it-IT = "<tip here>"
en-US = "<other tip here>"
}
required = false
constraint = "SameForAll"
type {
name = "set"
element_type {
name = "enum"
values = jsondecode(file("${path.module}/benefits.json"))
}
}
searchable = true
}
where benefits.json
was:
{
"key-one": "Label one",
"key-two": "Label two",
"key-three": "Label three",
"key-four": "Label four"
}
I have migrated the benefits.json
to:
{
"values": [
{ "key": "key-one", "label": "Label one" },
{ "key": "key-two", "label": "Label two" },
{ "key": "key-three", "label": "Label three" },
{ "key": "key-four", "label": "Label four" }
]
}
and the tf code to:
locals {
# [...]
benefits = jsondecode(file("${path.module}/benefits.json"))
}
resource "commercetools_product_type" "tree" {
# [....]
attribute {
name = "fake-name"
label = {
it-IT = "<label here>"
en-US = "<other label here>"
}
input_tip = {
it-IT = "<tip here>"
en-US = "<other tip here>"
}
required = false
constraint = "SameForAll"
type {
name = "set"
element_type {
name = "enum"
dynamic "value" {
for_each = local.benefits.values
content {
key = value.value.key
label = value.value.label
}
}
}
}
searchable = true
}
# [...]
}
Anyway I have this diff:
~ attribute {
name = "fake-name"
# (6 unchanged attributes hidden)
~ type {
name = "set"
~ element_type {
name = "enum"
~ value {
~ key = "key-four" -> "key-one"
~ label = "Label four" -> "Label one"
}
~ value {
~ key = "key-one" -> "key-three"
~ label = "Label one" -> "Label three"
}
~ value {
~ key = "key-three" -> "key-four"
~ label = "Label three" -> "Label four"
}
# (1 unchanged block hidden)
}
}
}
# (22 unchanged blocks hidden)
}
Anyway I see that there is a closed bug report that states that this problem should be solved.
Any hints? Thanks!
demeyerthom commented
Hi @lorenzosfarra! Appologies for the late reply.
I have tried to reproduce this with your code example, but it does not seem to make any diff for me when rerunning (with the latest provider version). What version of terraform are you using?