AWS Identity Store - how iterate over all users

Hi,
I’m looking for a way to get a list of AWS Identity Store users which I can use in a for_each clause to create a resource for every user.

Currently I have the following:

resource “aws_cloudwatch_metric_alarm” “user_specific_alarm” {
for_each = toset(var.sso_users)

}
variable “sso_users” {
type = list(any)
default = [
“user1”,
“user2”,
]
}

But I’d like to use a datasource which returns the list of actual identity store users rather than a hardcoded variable… much like the output of the AWS cli command:

aws identitystore list-users --identity-store-id d-111111111

I’ve tried using a “external” data source to call the AWS cli directly but can’t get it to accept the output from the command.

Any pointers?