How to get the distinct map value for the list obect to create resources

Hi @janapb,

It seems like your first and third object are totally identical and so there isn’t any way to distinguish them with just the information given here.

Perhaps by “distinct map object” you mean that you’d like to just discard that duplicate object and keep only one of them? If that’s your goal then one way to achieve that would be to convert your list into a set of objects first, because the set data structure has the characteristic that each distinct value is either in the set or not in the set… there is no sense of the values being in any particular order or appearing more than once.

You can use the toset function to convert from a list to a set, silently discarding any duplicate values. You could then convert the result into a map however you already tried to do it and know that all of the duplicate objects were removed.

Note that toset on a list of objects will use the entire object value to decide about whether a value is a duplicate, rather than just the Resourcegroup_Name key, and so it’d still be invalid to have two different objects with the same name, but it’d be acceptable to have two objects of the same name as long as all of their other attributes are also equal.