# Resource Groups for The Order
# Creates resource groups for each environment
# Naming: az-we-rg-dev-main (provider-region-resource-env-purpose) or custom from variable

resource "azurerm_resource_group" "main" {
  name     = var.resource_group_name != "" ? var.resource_group_name : local.rg_name
  location = var.azure_region

  tags = merge(var.tags, {
    Purpose = "Main"
  })
}

# Resource group for Terraform state (if using remote backend)
resource "azurerm_resource_group" "terraform_state" {
  count    = var.create_terraform_state_rg ? 1 : 0
  name     = local.rg_state_name
  location = var.azure_region

  tags = merge(local.common_tags, {
    Purpose = "TerraformState"
  })
}

