You get the map with id=”name2″ with the following expression:
var.objects[index(var.objects.*.id, "name2")]
For a quick test, run the following one-liner in terraform console:
[{id = "name1", attribute = "a"}, {id = "name2", attribute = "a,b"}, {id = "name3", attribute = "d"}][index([{id = "name1", attribute = "a"}, {id = "name2", attribute = "a,b"}, {id = "name3", attribute = "d"}].*.id, "name2")]