# Region-specific configurations for multi-region deployment

variable "regions" {
  description = "List of Azure regions for deployment"
  type        = list(string)
  default     = ["westeurope", "northeurope", "francecentral"]
}

variable "region_configs" {
  description = "Region-specific configurations"
  type = map(object({
    validator_count    = number
    sentry_count       = number
    rpc_count          = number
    node_pool_size     = string
    storage_type       = string
  }))
  default = {
    eastus = {
      validator_count = 2
      sentry_count    = 2
      rpc_count       = 2
      node_pool_size  = "Standard_D4s_v3"
      storage_type    = "Premium_LRS"
    }
    westus = {
      validator_count = 2
      sentry_count    = 2
      rpc_count       = 2
      node_pool_size  = "Standard_D4s_v3"
      storage_type    = "Premium_LRS"
    }
    westeurope = {
      validator_count = 2
      sentry_count    = 2
      rpc_count       = 2
      node_pool_size  = "Standard_D4s_v3"
      storage_type    = "Premium_LRS"
    }
  }
}

# Region-specific resource groups
resource "azurerm_resource_group" "region_rg" {
  for_each = toset(var.regions)
  
  name     = "defi-oracle-mainnet-${each.value}-rg"
  location = each.value
  
  tags = {
    Environment = "production"
    Region      = each.value
    Component   = "besu-network"
  }
}

# Region monitoring
resource "azurerm_monitor_action_group" "region_alerts" {
  for_each = toset(var.regions)
  
  name                = "region-${each.value}-alerts"
  resource_group_name = azurerm_resource_group.region_rg[each.value].name
  short_name          = "region-${each.value}"
  
  email_receiver {
    name          = "admin"
    email_address = "admin@example.com"
  }
}

