Skip to content

Commit

Permalink
[Modules] Configure privateDnsZoneGroups on eventgrid (#2003)
Browse files Browse the repository at this point in the history
* privateDNSResourceIds and min test

* readme

* inboundIpRules  and pe test

* inboundIpRules object

* readme

* version

* inboundIpRules description

* output description
  • Loading branch information
eriqua authored Sep 9, 2022
1 parent 03c0e8e commit 768404b
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 12 deletions.
9 changes: 9 additions & 0 deletions modules/Microsoft.EventGrid/topics/.test/min.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<<namePrefix>>-az-egtn-min-001"
}
}
}
15 changes: 14 additions & 1 deletion modules/Microsoft.EventGrid/topics/.test/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@
}
]
},
"inboundIpRules": {
"value": [
{
"action": "Allow",
"ipMask": "40.74.28.0/23"
}
]
},
"privateEndpoints": {
"value": [
{
"subnetResourceId": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<<namePrefix>>-az-vnet-x-001/subnets/<<namePrefix>>-az-subnet-x-005-privateEndpoints",
"service": "topic"
"service": "topic",
"privateDnsZoneGroup": {
"privateDNSResourceIds": [
"/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/privateDnsZones/privatelink.eventgrid.azure.net"
]
}
}
]
},
Expand Down
22 changes: 22 additions & 0 deletions modules/Microsoft.EventGrid/topics/.test/pe.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<<namePrefix>>-az-egtn-pe-001"
},
"privateEndpoints": {
"value": [
{
"subnetResourceId": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<<namePrefix>>-az-vnet-x-001/subnets/<<namePrefix>>-az-subnet-x-005-privateEndpoints",
"service": "topic",
"privateDnsZoneGroup": {
"privateDNSResourceIds": [
"/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/privateDnsZones/privatelink.eventgrid.azure.net"
]
}
}
]
}
}
}
10 changes: 5 additions & 5 deletions modules/Microsoft.EventGrid/topics/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ param name string
@description('Optional. Location for all Resources.')
param location string = resourceGroup().location

@description('Optional. Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set.')
@description('Optional. Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set and inboundIpRules are not set.')
@allowed([
''
'Enabled'
'Disabled'
])
param publicNetworkAccess string = ''

@description('Optional. Array of IPs to whitelist.')
@description('Optional. This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled.')
param inboundIpRules array = []

@description('Optional. Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely.')
Expand Down Expand Up @@ -111,7 +111,7 @@ resource topic 'Microsoft.EventGrid/topics@2020-06-01' = {
location: location
tags: tags
properties: {
publicNetworkAccess: !empty(publicNetworkAccess) ? any(publicNetworkAccess) : (!empty(privateEndpoints) ? 'Disabled' : null)
publicNetworkAccess: !empty(publicNetworkAccess) ? any(publicNetworkAccess) : (!empty(privateEndpoints) && empty(inboundIpRules) ? 'Disabled' : null)
inboundIpRules: (empty(inboundIpRules) ? null : inboundIpRules)
}
}
Expand Down Expand Up @@ -174,10 +174,10 @@ module topic_roleAssignments '.bicep/nested_roleAssignments.bicep' = [for (roleA
@description('The name of the event grid topic.')
output name string = topic.name

@description('The resource ID of the event grid.')
@description('The resource ID of the event grid topic.')
output resourceId string = topic.id

@description('The name of the resource group the event grid was deployed into.')
@description('The name of the resource group the event grid topic was deployed into.')
output resourceGroupName string = resourceGroup().name

@description('The location the resource was deployed into.')
Expand Down
136 changes: 131 additions & 5 deletions modules/Microsoft.EventGrid/topics/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ This module deploys an event grid topic.
| `diagnosticStorageAccountId` | string | `''` | | Resource ID of the diagnostic storage account. |
| `diagnosticWorkspaceId` | string | `''` | | Resource ID of the diagnostic log analytics workspace. |
| `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via the Customer Usage Attribution ID (GUID). |
| `inboundIpRules` | array | `[]` | | Array of IPs to whitelist. |
| `inboundIpRules` | array | `[]` | | This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. |
| `location` | string | `[resourceGroup().location]` | | Location for all Resources. |
| `lock` | string | `''` | `['', CanNotDelete, ReadOnly]` | Specify the type of lock. |
| `privateEndpoints` | array | `[]` | | Configuration details for private endpoints. For security reasons, it is recommended to use private endpoints whenever possible. |
| `publicNetworkAccess` | string | `''` | `['', Disabled, Enabled]` | Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set. |
| `publicNetworkAccess` | string | `''` | `['', Disabled, Enabled]` | Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set and inboundIpRules are not set. |
| `roleAssignments` | array | `[]` | | Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalId' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. |
| `tags` | object | `{object}` | | Tags of the resource. |

Expand Down Expand Up @@ -236,8 +236,8 @@ tags: {
| :-- | :-- | :-- |
| `location` | string | The location the resource was deployed into. |
| `name` | string | The name of the event grid topic. |
| `resourceGroupName` | string | The name of the resource group the event grid was deployed into. |
| `resourceId` | string | The resource ID of the event grid. |
| `resourceGroupName` | string | The name of the resource group the event grid topic was deployed into. |
| `resourceId` | string | The resource ID of the event grid topic. |

## Cross-referenced modules

Expand All @@ -254,7 +254,44 @@ The following module usage examples are retrieved from the content of the files
>**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order.
<h3>Example 1: Parameters</h3>
<h3>Example 1: Min</h3>

<details>

<summary>via Bicep module</summary>

```bicep
module topics './Microsoft.EventGrid/topics/deploy.bicep' = {
name: '${uniqueString(deployment().name)}-Topics'
params: {
name: '<<namePrefix>>-az-egtn-min-001'
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<<namePrefix>>-az-egtn-min-001"
}
}
}
```

</details>
<p>

<h3>Example 2: Parameters</h3>

<details>

Expand All @@ -272,9 +309,20 @@ module topics './Microsoft.EventGrid/topics/deploy.bicep' = {
diagnosticLogsRetentionInDays: 7
diagnosticStorageAccountId: '/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<<namePrefix>>azsax001'
diagnosticWorkspaceId: '/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<<namePrefix>>-az-law-x-001'
inboundIpRules: [
{
action: 'Allow'
ipMask: '40.74.28.0/23'
}
]
lock: 'CanNotDelete'
privateEndpoints: [
{
privateDnsZoneGroup: {
privateDNSResourceIds: [
'/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/privateDnsZones/privatelink.eventgrid.azure.net'
]
}
service: 'topic'
subnetResourceId: '/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<<namePrefix>>-az-vnet-x-001/subnets/<<namePrefix>>-az-subnet-x-005-privateEndpoints'
}
Expand Down Expand Up @@ -323,12 +371,25 @@ module topics './Microsoft.EventGrid/topics/deploy.bicep' = {
"diagnosticWorkspaceId": {
"value": "/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<<namePrefix>>-az-law-x-001"
},
"inboundIpRules": {
"value": [
{
"action": "Allow",
"ipMask": "40.74.28.0/23"
}
]
},
"lock": {
"value": "CanNotDelete"
},
"privateEndpoints": {
"value": [
{
"privateDnsZoneGroup": {
"privateDNSResourceIds": [
"/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/privateDnsZones/privatelink.eventgrid.azure.net"
]
},
"service": "topic",
"subnetResourceId": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<<namePrefix>>-az-vnet-x-001/subnets/<<namePrefix>>-az-subnet-x-005-privateEndpoints"
}
Expand All @@ -350,3 +411,68 @@ module topics './Microsoft.EventGrid/topics/deploy.bicep' = {

</details>
<p>

<h3>Example 3: Pe</h3>

<details>

<summary>via Bicep module</summary>

```bicep
module topics './Microsoft.EventGrid/topics/deploy.bicep' = {
name: '${uniqueString(deployment().name)}-Topics'
params: {
// Required parameters
name: '<<namePrefix>>-az-egtn-pe-001'
// Non-required parameters
privateEndpoints: [
{
privateDnsZoneGroup: {
privateDNSResourceIds: [
'/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/privateDnsZones/privatelink.eventgrid.azure.net'
]
}
service: 'topic'
subnetResourceId: '/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<<namePrefix>>-az-vnet-x-001/subnets/<<namePrefix>>-az-subnet-x-005-privateEndpoints'
}
]
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
// Required parameters
"name": {
"value": "<<namePrefix>>-az-egtn-pe-001"
},
// Non-required parameters
"privateEndpoints": {
"value": [
{
"privateDnsZoneGroup": {
"privateDNSResourceIds": [
"/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/privateDnsZones/privatelink.eventgrid.azure.net"
]
},
"service": "topic",
"subnetResourceId": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<<namePrefix>>-az-vnet-x-001/subnets/<<namePrefix>>-az-subnet-x-005-privateEndpoints"
}
]
}
}
}
```

</details>
<p>
2 changes: 1 addition & 1 deletion modules/Microsoft.EventGrid/topics/version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.4"
"version": "0.5"
}

0 comments on commit 768404b

Please sign in to comment.