Loop in templatefile

Hi

Can someone help me with templating the bash script which I’m using as user data for creating 3 different ec2 instances?

I have a local

locals {
  connection_parameters = {
    "worker-1" = {
      "url"    = "https://some.site"
      "secret" = "secret"
    },
    "worker-2" = {
      "url"    = "https://some.site"
      "secret" = "secret"
    },
    "worker-3" = {
      "url"    = "https://some.site"
      "secret" = "secret"
    }
  }
 }
}

What should I do to be able to use these values in my bash script?