Each.value.<key> and nested maps not returning attributes

I’m trying to create opsgenie users and teams using opsgenie providers.
Currently, I’m having issues assigning users to the team using nested loops. This is how my basic file looks like:

main.tf

locals {
users_list = {
mahela@domain.com” = “Mahela Jaya”,
bhanuka@domain.com” = “Bhanu Kumar”,
duminda@domain.com” = “Duminda Gupta”
}
}

resource “opsgenie_user” “create_users” {
role = “User”
for_each = local.users_list
username = each.key
full_name = each.value
}

locals {
out_list = flatten([ for index in opsgenie_user.create_users: {
username = index.username
}
])
}

output “out_list” {
value = local.out_list
}

resource “opsgenie_team” “my_team” {
name = “First Team”
description = “This team deals with all the things”
for_each = { for my_user in local.out_list : my_user.username => my_user }

member {
id = opsgenie_user.create_users[each.value]
role = “admin”
}
}

===
I wanted to create some users & assign these users to a team “First Team”.

try the above, it seems you missed calling the id