Azure / Azure/Azure-Landing-Zones
Eventgrid - Topic - Private dns zone policy
- Dominant language
- PowerShell
- Stars
- 96
- Forks
- 70
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 7
Description
**Describe the bug**
The Azure Policy Set for "deploy-private-dns-zones" contains a policy definition parameter for DINE-Private-DNS-Azure-EventGridTopics.
Which uses the following [logic](https://github.com/Azure/Enterprise-Scale/blob/main/src/resources/Microsoft.Authorization/policySetDefinitions/Deploy-Private-DNS-Zones.json#L1434)
```
[[if(equals(parameters('dnsZoneSubscriptionId'), ''), parameters('azureEventGridTopicsPrivateDnsZoneId'), format('/subscriptions/{0}/resourceGroups/{1}/providers/{2}/{3}', parameters('dnsZoneSubscriptionId'), toLower(parameters('dnsZoneResourceGroupName')), parameters('dnsZoneResourceType'), replace(replace(parameters('dnsZoneNames').azureEventGridTopicsPrivateDnsZoneId, '{regionName}', parameters('dnsZoneRegion')), '{regionCode}', parameters('dnzZoneRegionShortNames')[parameters('dnsZoneRegion')])))]
```
However when the parameter 'dnsZoneSubscriptionId' is defined, and we get in the if clause to format the string, it will try and replace '{regionCode}' and/or '{regionName}'.
However the default value of the parameter dnsZoneNames with key 'azureEventGridTopicsPrivateDnsZoneId' is
`
"privatelink.eventgrid.azure.net"
`
Reference; [azureEventGridTopicsPrivateDnsZoneId](https://github.com/Azure/Enterprise-Scale/blob/b72497573d9d67efc322f5ce147670f9e196b789/src/resources/Microsoft.Authorization/policySetDefinitions/Deploy-Private-DNS-Zones.json#L146)
According to the Event grid documentations the expected DNS zone should be in the following format;
`
..privatelink.eventgrid.azure.net
`
However it also states;
> The recommended DNS zone name is privatelink.eventgrid.azure.net.
Which makes the initiative go against the recommendation.
Reference; https://learn.microsoft.com/en-us/azure/event-grid/network-security#dns-changes-for-private-endpoints
This means that the logic done per default does not work and will only start creating entries in the dns zone 'privatelink.eventgrid.azure.net'.
This is not a valid CNAME according to documentation as it must always have RegionName appended.
Contributor guide
Research direction
Start with src/resources/Microsoft.Authorization/policySetDefinitions/Deploy-Private-DNS-Zones.json, especially the Event Grid policy logic and the default azureEventGridTopicsPrivateDnsZoneId value. Compare the generated zone name with the referenced Event Grid DNS documentation. Done means the policy's default behavior produces a DNS zone name valid for Event Grid private endpoints and remains consistent with the documented recommendation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100