module "cloudfront" {
  for_each = local.cloudfront
  source   = "../modules/cloudfront"

  providers = {
    aws = aws.aws
  }

  enabled    = true
  web_acl_id = try(each.value.web_acl_id, null)
  aliases    = each.value.aliases

  acm_certificate_arn = module.acm.certificate_arn
  default_root_object = "index.html"

  origin = each.value.origin

  default_cache_behavior = each.value.default_cache_behavior
  code                   = try(each.value.code, "")
}
