Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable avm/res/network/virtual-network/subnet publishing #4410

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions avm/res/network/virtual-network/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ param enableTelemetry bool = true
@description('Optional. Indicates if VM protection is enabled for all the subnets in the virtual network.')
param enableVmProtection bool?

var enableReferencedModulesTelemetry = false

var builtInRoleNames = {
Contributor: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
'Network Contributor': subscriptionResourceId(
Expand Down Expand Up @@ -168,6 +170,7 @@ module virtualNetwork_subnets 'subnet/main.bicep' = [
serviceEndpoints: subnet.?serviceEndpoints
defaultOutboundAccess: subnet.?defaultOutboundAccess
sharingScope: subnet.?sharingScope
enableTelemetry: enableReferencedModulesTelemetry
}
}
]
Expand Down
47 changes: 39 additions & 8 deletions avm/res/network/virtual-network/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "2376075998560091019"
"version": "0.33.13.18514",
"templateHash": "17461823572424139738"
},
"name": "Virtual Networks",
"description": "This module deploys a Virtual Network (vNet)."
Expand Down Expand Up @@ -627,6 +627,7 @@
"input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
}
],
"enableReferencedModulesTelemetry": false,
"builtInRoleNames": {
"Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
"Network Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '4d97b98b-1d4f-4787-a291-c67834d212e7')]",
Expand Down Expand Up @@ -816,6 +817,9 @@
},
"sharingScope": {
"value": "[tryGet(coalesce(parameters('subnets'), createArray())[copyIndex()], 'sharingScope')]"
},
"enableTelemetry": {
"value": "[variables('enableReferencedModulesTelemetry')]"
}
},
"template": {
Expand All @@ -825,8 +829,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "6924527964815690853"
"version": "0.33.13.18514",
"templateHash": "15508131240272677845"
},
"name": "Virtual Network Subnets",
"description": "This module deploys a Virtual Network Subnet."
Expand Down Expand Up @@ -1041,6 +1045,13 @@
"metadata": {
"description": "Optional. Array of role assignments to create."
}
},
"enableTelemetry": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Optional. Enable/Disable usage telemetry for module."
}
}
},
"variables": {
Expand All @@ -1061,6 +1072,26 @@
}
},
"resources": {
"avmTelemetry": {
"condition": "[parameters('enableTelemetry')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2024-03-01",
"name": "[format('46d3xbcp.res.network-virtualnetworksubnet.{0}.{1}', replace('-..--..-', '.', '-'), substring(uniqueString(deployment().name), 0, 4))]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [],
"outputs": {
"telemetry": {
"type": "String",
"value": "For more information, see https://aka.ms/avm/TelemetryInfo"
}
}
}
}
},
"virtualNetwork": {
"existing": true,
"type": "Microsoft.Network/virtualNetworks",
Expand Down Expand Up @@ -1206,8 +1237,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "6667873480569726785"
"version": "0.33.13.18514",
"templateHash": "3926757544002464477"
},
"name": "Virtual Network Peerings",
"description": "This module deploys a Virtual Network Peering."
Expand Down Expand Up @@ -1363,8 +1394,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "6667873480569726785"
"version": "0.33.13.18514",
"templateHash": "3926757544002464477"
},
"name": "Virtual Network Peerings",
"description": "This module deploys a Virtual Network Peering."
Expand Down
14 changes: 14 additions & 0 deletions avm/res/network/virtual-network/subnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This module deploys a Virtual Network Subnet.
- [Outputs](#Outputs)
- [Cross-referenced modules](#Cross-referenced-modules)
- [Notes](#Notes)
- [Data Collection](#Data-Collection)

## Resource Types

Expand Down Expand Up @@ -40,6 +41,7 @@ This module deploys a Virtual Network Subnet.
| [`applicationGatewayIPConfigurations`](#parameter-applicationgatewayipconfigurations) | array | Application gateway IP configurations of virtual network resource. |
| [`defaultOutboundAccess`](#parameter-defaultoutboundaccess) | bool | Set this property to false to disable default outbound connectivity for all VMs in the subnet. This property can only be set at the time of subnet creation and cannot be updated for an existing subnet. |
| [`delegation`](#parameter-delegation) | string | The delegation to enable on the subnet. |
| [`enableTelemetry`](#parameter-enabletelemetry) | bool | Enable/Disable usage telemetry for module. |
| [`natGatewayResourceId`](#parameter-natgatewayresourceid) | string | The resource ID of the NAT Gateway to use for the subnet. |
| [`networkSecurityGroupResourceId`](#parameter-networksecuritygroupresourceid) | string | The resource ID of the network security group to assign to the subnet. |
| [`privateEndpointNetworkPolicies`](#parameter-privateendpointnetworkpolicies) | string | Enable or disable apply network policies on private endpoint in the subnet. |
Expand Down Expand Up @@ -100,6 +102,14 @@ The delegation to enable on the subnet.
- Required: No
- Type: string

### Parameter: `enableTelemetry`

Enable/Disable usage telemetry for module.

- Required: No
- Type: bool
- Default: `True`

### Parameter: `natGatewayResourceId`

The resource ID of the NAT Gateway to use for the subnet.
Expand Down Expand Up @@ -306,3 +316,7 @@ This section gives you an overview of all local-referenced module files (i.e., o
## Notes

The `privateEndpointNetworkPolicies` property must be set to disabled for subnets that contain private endpoints. It confirms that NSGs rules will not apply to private endpoints (currently not supported, [reference](https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-overview#limitations)). Default Value when not specified is "Enabled".

## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the [repository](https://aka.ms/avm/telemetry). There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
22 changes: 22 additions & 0 deletions avm/res/network/virtual-network/subnet/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ import { roleAssignmentType } from 'br/public:avm/utl/types/avm-common-types:0.2
@description('Optional. Array of role assignments to create.')
param roleAssignments roleAssignmentType[]?

@description('Optional. Enable/Disable usage telemetry for module.')
param enableTelemetry bool = true

var builtInRoleNames = {
Contributor: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
'Network Contributor': subscriptionResourceId(
Expand Down Expand Up @@ -89,6 +92,25 @@ var formattedRoleAssignments = [
})
]

#disable-next-line no-deployments-resources
resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableTelemetry) {
name: '46d3xbcp.res.network-virtualnetworksubnet.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name), 0, 4)}'
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
resources: []
outputs: {
telemetry: {
type: 'String'
value: 'For more information, see https://aka.ms/avm/TelemetryInfo'
}
}
}
}
}

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2024-01-01' existing = {
name: virtualNetworkName
}
Expand Down
31 changes: 29 additions & 2 deletions avm/res/network/virtual-network/subnet/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "6924527964815690853"
"version": "0.33.13.18514",
"templateHash": "15508131240272677845"
},
"name": "Virtual Network Subnets",
"description": "This module deploys a Virtual Network Subnet."
Expand Down Expand Up @@ -221,6 +221,13 @@
"metadata": {
"description": "Optional. Array of role assignments to create."
}
},
"enableTelemetry": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Optional. Enable/Disable usage telemetry for module."
}
}
},
"variables": {
Expand All @@ -241,6 +248,26 @@
}
},
"resources": {
"avmTelemetry": {
"condition": "[parameters('enableTelemetry')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2024-03-01",
"name": "[format('46d3xbcp.res.network-virtualnetworksubnet.{0}.{1}', replace('-..--..-', '.', '-'), substring(uniqueString(deployment().name), 0, 4))]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [],
"outputs": {
"telemetry": {
"type": "String",
"value": "For more information, see https://aka.ms/avm/TelemetryInfo"
}
}
}
}
},
"virtualNetwork": {
"existing": true,
"type": "Microsoft.Network/virtualNetworks",
Expand Down
7 changes: 7 additions & 0 deletions avm/res/network/virtual-network/subnet/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#",
"version": "0.1",
"pathFilters": [
"./main.json"
]
}
2 changes: 1 addition & 1 deletion avm/res/network/virtual-network/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#",
"version": "0.5",
"version": "0.6",
"pathFilters": [
"./main.json"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "6667873480569726785"
"version": "0.33.13.18514",
"templateHash": "3926757544002464477"
},
"name": "Virtual Network Peerings",
"description": "This module deploys a Virtual Network Peering."
Expand Down