/** * Microsoft Azure Custom Security Policies * Maintained by Sachan & Partners (https://sachanpartners.co.uk) */ # 1. Deny direct Public IP attachments to Virtual Machine Network Interfaces resource "azurerm_policy_definition" "deny_vm_public_ip" { name = "deny-nic-public-ip" policy_type = "Custom" mode = "Indexed" display_name = "Deny Public IP on Network Interfaces" policy_rule = jsonencode({ if = { allOf = [ { field = "type", equals = "Microsoft.Network/networkInterfaces" }, { not = { field = "Microsoft.Network/networkInterfaces/ipConfigurations[*].publicIpAddress.id", exists = false } } ] } then = { effect = "deny" } }) }