variable "oidc_issuer" {
  type = string
}

variable "oidc_arn" {
  type = string
}

variable "env" {
  type = string
}

variable "logical_region_name" {
  type = string
}

variable "auto_deploy_owner_tag" {
  type = string
}

locals {
  # billing-sqs-dev-reporter does not exist; fall back to staging policy for dev
  billing_sqs_policy_env = var.env == "dev" ? "staging" : var.env
}

module "billing-reporter" {
  source = "../ram_modules/controlplane"

  oidc_issuer = var.oidc_issuer
  oidc_arn    = var.oidc_arn
  role_name   = "${var.logical_region_name}-billing-${var.env}-reporter"
  custom_policies = [
    "billing-sqs-${local.billing_sqs_policy_env}-reporter",
  ]
  auto_deploy_owner_tag = var.auto_deploy_owner_tag
}

output "role_id" {
  value = module.billing-reporter.controlplane_role_id
}

output "role_name" {
  value = module.billing-reporter.controlplane_role_name
}

output "role_arn" {
  value = module.billing-reporter.controlplane_role_arn
}
