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