Datadog monitor message loop

Hi looking for some help building a monitor message with a loop.
What I want to achieve is a string that build from a list and will be using in {{is_match}} block

So lets say I have a map of matches:

Variable matches-map {
Default = {
A = “@opsgenie-group-a
B = “@opsgenie-group-b
}
}

resource "datadog_monitor" "foo" {
  name               = "Name for monitor foo"
  type               = "metric alert"
  message            = "{{is_match A}} alert @opsgenie- group-a {{/is_match}}
{{Is_match B}} alert @opsgenie-group-b{{/is_match}}..

My list is very long and will be hard to update in the future. Is there anyway that i can get the match and group in some loop?:thinking::crossed_fingers::crossed_fingers:

Very appreciated

Thanks,
Assaf