Morning. I’m testing using a ‘for_each’ to create a large number of workspaces with identical attributes. This replaces some individual workspace creation syntax.
Surprisingly, I see the ‘plan’ saying that it’ll destroy and create everything.
I’ve recreated with a test case: relevant parts below.
Simple creates:
resource “fabric_workspace” “Raw” {
display_name = “JBTEST Raw${local.envsuffix}”
description = “JBTEST_Raw”
capacity_id = var.fabric_capacity_id
}
resource “fabric_workspace” “Raw_D365” {
display_name = “JBTEST Raw D365${local.envsuffix}”
description = “JBTEST_Raw_D365”
capacity_id = var.fabric_capacity_id
}
Then advanced …
Using a 'for_each" variable defined this way
variable workspace_maps_C {
description = “Workspace display names (key) and descriptions (value)”
type = map(string)
default = {
“JBTEST Raw” = “JBTEST_Raw”
“JBTEST Raw D365” = “JBTEST_Raw_D365”
}
}
And the workspaces…
resource “fabric_workspace” “jbtest_workspace_C” {
for_each = var.workspace_maps_C
display_name = “{each.key}{local.envsuffix}”
description = “${each.value}”
capacity_id = var.fabric_capacity_id
}
The second one can’t match the workspace names in the ‘plan’ - but then when I push it through it can’t create the new ones… as they already exist.
Issue looks to be in the way the plan compares the TFstate files.
I’m in Terraform provider 1.10.4.
Any thoughts?