Want to DRY up this loop of buckets creation

Hello!

I call a module to create buckets for static sites in AWS.

I loop over a local to create multiple buckets per environment. I now need to duplicate some of these buckets and just modify the name of the key. I’ve been trying all sorts of tricks to do this but haven’t had much luck, I know I can easily make this work (just hardcoding a large locals map) by just creating an entry in the local variable for each site–but that will be ugly.

Here is a piece of the local variable:

locals {
  static-site-template = {
    "site.mysite.io" = {
       acl                  = "public-read"
      index_document       = "index.html"
      error_document       = "index.html"
      }
    "app.mysite.io" = {
      acl                  = "public-read"
      index_document       = "index.html"
      error_document       = "index.html"
      }
    "admin.mysite.io" = {
      acl                  = "public-read"
      index_document       = "index.html"
      error_document       = "index.html"
     }

Here are the pre-fix variables I’d like to append on the bucket names (which are the each.key in the local.static-site-template)

variable "qa_and_demo_envs" {
	default = [
		"qa1",
		"qa2",
		"qa3",
		"demo1",
		"demo2"
	]
}

Here are the relevant pieces of the calling module

module "s3-site" {
  for_each = local.static-site-template
  source   = "./modules/static-sites"

  site_name            = each.key
  acl                  = each.value.acl
  index_document       = each.value.index_document
  error_document       = each.value.error_documen

I’ve tried to combine the var.qa_and_demo_envs with local.static-site-template into a single map and then pass that single map through the for_each of the module without luck.

I either want a combined local map like this:

# All 15 sites with the key being updated with the suffix env
locals {
  static-site-template = {
    "qa1-site.mysite.io" = {
       acl                  = "public-read"
      index_document       = "index.html"
      error_document       = "index.html"
      }
....
    "demo2-app.mysite.io" = {
      acl                  = "public-read"
      index_document       = "index.html"
      error_document       = "index.html"
      }
...
    "qa2-admin.mysite.io" = {
      acl                  = "public-read"
      index_document       = "index.html"
      error_document       = "index.html"
     }

or a way to loop over the module using a for var.qa_and_demo_envs then the for_each local.static-site-template and having the: site_name = “{each.var}-{each.key}”

Any help would be appreciated!!!