terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~>3.0"
    }
  }
  backend "azurerm" {}
}
provider "azurerm" {
  subscription_id = var.subscription_id
  features {
    resource_group {
      prevent_deletion_if_contains_resources = false
    }
  }
}
data "azurerm_subscription" "primary" {}

variable "env" {
  type = string
}
variable "location" {
  type = string
}
variable "aks_oidc_issuer" {
  type = string
}
variable "subscription_id" {
  type = string
}
variable "principal_id" {
  type = string
}


# azure ad group settings
data "azuread_group" "control-plane-services" {
  display_name     = "${var.env}-control-plane-services"
  security_enabled = true
}

resource "azuread_group_member" "control-plane-services-o11y-regional-server" {
  group_object_id  = data.azuread_group.control-plane-services.object_id
  member_object_id = var.principal_id
}
