[terraform-modules] how to call public_ip_address_id in main.tf

Case: private ip
module main.tf
private_ip_address_allocation = var.m_private_ip_allocation
private_ip_address = var.m_private_ip_addres

call module main.tf
m_private_ip_address = var.private_ip_address
m_private_ip_allocation = var.private_ip_address_allocation

With private Ip is working fine but with public ip what should I put?

case public ip
module main.tf

Create public IPs

resource “azurerm_public_ip” “public_ip” {

name = var.public_ip_name

location = var.m_location

resource_group_name = “infsdbdbsrg001”

allocation_method = “Dynamic”

tags = {

environment = "production"

}
//Create new NIC and attach SubNet + (optional)NSG to it

resource “azurerm_network_interface” “az_nic” {

name = “{var.m_domain_name}{var.m_environment}{var.m_vm_role}{var.m_vm_type}{var.m_instance}{var.m_nic_type}${var.m_nic_instance}”

location = var.m_location

resource_group_name = var.m_resource_group_name

tags = merge(var.m_common_tag, { “fonction” = var.m_tag_nic_function })

ip_configuration {

name                          = var.m_ip_config_name

subnet_id                     = data.azurerm_subnet.az_subnet.id

private_ip_address_allocation = var.m_private_ip_allocation

public_ip_address_id          = azurerm_public_ip.public_ip.id

}

enable_accelerated_networking = var.m_nic_enable_acc_networking

}

call module main.tf
how to call this resource
public_ip_address_id = azurerm_public_ip.public_ip.id

Could you create and share a sample repo and reformat (edit) above code properly?