Duplicate key error on core

Hi,
I am getting this error can you please help me resolve it.

Planning failed. Terraform encountered an error while generating this plan.


│ Error: Duplicate object key

│ on .terraform\modules\enterprise_scale\modules\archetypes\locals.policy_assignments.tf line 52, in locals:
│ 50: custom_policy_assignments_map_from_json = try(length(local.custom_policy_assignments_dataset_from_json) > 0, false) ? {
│ 51: for key, value in local.custom_policy_assignments_dataset_from_json :
│ 52: value.name => value
│ 53: if value.type == local.resource_types.policy_assignment
│ 54: } : null
│ ├────────────────
│ │ value.name is “Deny-NIC-NSG”

│ Two different items produced the key “Deny-NIC-NSG” in this ‘for’ expression. If duplicates are expected, use the ellipsis (…) after the value expression to enable grouping by key.

This is my code

custom_policy_assignments_map_from_json = try(length(local.custom_policy_assignments_dataset_from_json) > 0, false) ? {
for key, value in local.custom_policy_assignments_dataset_from_json :
value.name => value
if value.type == local.resource_types.policy_assignment
} : null

Hi,
Can you provide an example of the data in the above local variable, please. As the error states: Two different items produced the key “Deny-NIC-NSG” - seeing the contents of that variable will allow us to explain what is happening to produce your error, and suggest how to fix it.

Also, when pasting code and text from a terminal, it is much easier for people to read, interpret and copy/paste out of your post if you use preformatted text.

You can use 3x ‘backtick’ characters on the line before and after your code blocks:
```
locals {
fred = “123”
}
```

Is then formatted as:

locals {
   fred = "123"
}

Or you can use the ‘<>’ button in the toolbar after highlighting code - this is good if you want to show something inline with your text.

Cheers!