output "vm_ids" {
  value       = var.use_scale_set ? azurerm_linux_virtual_machine_scale_set.besu_node[*].id : azurerm_linux_virtual_machine.besu_node[*].id
  description = "VM or VMSS IDs"
}

output "vm_private_ips" {
  value       = var.use_scale_set ? [] : azurerm_network_interface.besu_node[*].private_ip_address
  description = "Private IP addresses of VMs"
}

output "vm_public_ips" {
  value       = var.use_scale_set ? [] : (var.node_type == "sentry" || var.node_type == "rpc" ? azurerm_public_ip.besu_node[*].ip_address : [])
  description = "Public IP addresses of VMs (sentry and RPC types only; besu-node uses private IPs only)"
}

output "private_ip_addresses" {
  value       = var.use_scale_set ? [] : azurerm_network_interface.besu_node[*].private_ip_address
  description = "Private IP addresses of VMs (alias for vm_private_ips)"
}

output "public_ip_addresses" {
  value       = var.use_scale_set ? [] : (var.node_type == "sentry" || var.node_type == "rpc" ? azurerm_public_ip.besu_node[*].ip_address : [])
  description = "Public IP addresses of VMs (alias for vm_public_ips - sentry and RPC types only; besu-node uses private IPs only)"
}

output "location" {
  value       = var.location
  description = "Location of the VMs"
}

output "vm_names" {
  value       = var.use_scale_set ? ["${var.cluster_name}-${var.node_type}-vmss"] : azurerm_linux_virtual_machine.besu_node[*].name
  description = "VM or VMSS names"
}

output "vmss_id" {
  value       = var.use_scale_set ? azurerm_linux_virtual_machine_scale_set.besu_node[0].id : null
  description = "VM Scale Set ID (if using scale set)"
}

output "principal_ids" {
  value       = var.use_scale_set ? (var.vm_enable_managed_identity ? [azurerm_linux_virtual_machine_scale_set.besu_node[0].identity[0].principal_id] : []) : (var.vm_enable_managed_identity ? [for vm in azurerm_linux_virtual_machine.besu_node : vm.identity[0].principal_id] : [])
  description = "Managed Identity principal IDs for VMs (for Key Vault access policies)"
}

