Interview Prep/Azure/Policy, Cost, AWS Mapping and Rapid-fire

Show an Azure Policy definition that denies public IPs on NICs.

AdvancedConceptPolicy, Cost, AWS Mapping and Rapid-fire
Answer
{
  "mode": "All",
  "policyRule": {
    "if": {
      "allOf": [
        { "field": "type", "equals": "Microsoft.Network/networkInterfaces" },
        { "count": { "field": "Microsoft.Network/networkInterfaces/ipconfigurations[*]",
            "where": { "field": "Microsoft.Network/networkInterfaces/ipconfigurations[*].publicIpAddress.id", "notEquals": "" } },
          "greater": 0 }
      ]
    },
    "then": { "effect": "deny" }
  }
}
az policy definition create -n deny-nic-pip --rules @rule.json --mode All
az policy assignment create -n deny-nic-pip --policy deny-nic-pip \
  --scope /providers/Microsoft.Management/managementGroups/corp

A built-in "Network interfaces should not have public IPs" exists; prefer built-ins where they fit.

Azure All Azure questions

More on Policy, Cost, AWS Mapping and Rapid-fire