Skip to content

Commit

Permalink
Release v1.1.2 - Fix 2 minor bug #26 & #27 (#28)
Browse files Browse the repository at this point in the history
* fix 🪲 Bug Report - `disableTelemetry` not being passed into child CARML modules and therefore some telemetry being left enabled #26

* fix 🪲 Bug Report - Creating subscriptions without networking resources causes management group placement and sub tags etc. to not be deployed/created #27

* Auto-update Bicep Module Docs for PR 28 [jtracey93/53f41446]

* update docs

* fix trailing whitespace

* Auto-update Bicep Module Docs for PR 28 [jtracey93/53f41446]

* move to single line

* Auto-update Bicep Module Docs for PR 28 [jtracey93/53f41446]

* change var name

* simplify

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jtracey93 and github-actions[bot] authored Dec 7, 2022
1 parent 53f4144 commit 5414104
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/wiki/Example-1-Hub-and-Spoke.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ targetScope = 'managementGroup'
@description('Specifies the location for resources.')
param location string = 'uksouth'
module sub003 'br/public:lz/sub-vending:1.1.1' = {
module sub003 'br/public:lz/sub-vending:1.1.2' = {
name: 'sub-bicep-lz-vending-example-001'
params: {
subscriptionAliasEnabled: true
Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/Example-2-Virtual-WAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ targetScope = 'managementGroup'
@description('Specifies the location for resources.')
param location string = 'uksouth'
module sub002 'br/public:lz/sub-vending:1.1.1' = {
module sub002 'br/public:lz/sub-vending:1.1.2' = {
name: 'sub-bicep-lz-vending-example-002'
params: {
subscriptionAliasEnabled: true
Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/Example-3-Use-With-Existing-Subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ targetScope = 'managementGroup'
@description('Specifies the location for resources.')
param location string = 'uksouth'
module sub003 'br/public:lz/sub-vending:1.1.1' = {
module sub003 'br/public:lz/sub-vending:1.1.2' = {
name: 'sub003'
params: {
subscriptionAliasEnabled: false
Expand Down
3 changes: 2 additions & 1 deletion main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ module createSubscription 'src/self/Microsoft.Subscription/aliases/deploy.bicep'
}
}

module createSubscriptionResources 'src/self/subResourceWrapper/deploy.bicep' = if ((subscriptionAliasEnabled || !empty(existingSubscriptionId)) && virtualNetworkEnabled && !empty(virtualNetworkResourceGroupName)) {
module createSubscriptionResources 'src/self/subResourceWrapper/deploy.bicep' = if (subscriptionAliasEnabled || !empty(existingSubscriptionId)) {
name: deploymentNames.createSubscriptionResources
params: {
subscriptionId: (subscriptionAliasEnabled && empty(existingSubscriptionId)) ? createSubscription.outputs.subscriptionId : existingSubscriptionId
Expand All @@ -467,6 +467,7 @@ module createSubscriptionResources 'src/self/subResourceWrapper/deploy.bicep' =
virtualNetworkVwanPropagatedLabels: virtualNetworkVwanPropagatedLabels
roleAssignmentEnabled: roleAssignmentEnabled
roleAssignments: roleAssignments
disableTelemetry: disableTelemetry
}
}

Expand Down
20 changes: 16 additions & 4 deletions src/self/subResourceWrapper/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ param virtualNetworkEnabled bool = false

@maxLength(90)
@sys.description('The name of the resource group to create the virtual network in.')
param virtualNetworkResourceGroupName string
param virtualNetworkResourceGroupName string = ''

@sys.description('Enables the deployment of a `CanNotDelete` resource locks to the virtual networks resource group.')
param virtualNetworkResourceGroupLockEnabled bool = true
Expand Down Expand Up @@ -80,6 +80,9 @@ param roleAssignmentEnabled bool = false
@sys.description('Supply an array of objects containing the details of the role assignments to create.')
param roleAssignments array = []

@sys.description('Disable telemetry collection by this module. For more information on the telemetry collected by this module, that is controlled by this parameter, see this page in the wiki: [Telemetry Tracking Using Customer Usage Attribution (PID)](https://github.com/Azure/bicep-lz-vending/wiki/Telemetry)')
param disableTelemetry bool = false

// VARIABLES

// Deployment name variables
Expand Down Expand Up @@ -110,6 +113,9 @@ var virutalWanHubDefaultRouteTableId = {
var virtualWanHubConnectionPropogatedRouteTables = !empty(virtualNetworkVwanPropagatedRouteTablesResourceIds) ? virtualNetworkVwanPropagatedRouteTablesResourceIds : array(virutalWanHubDefaultRouteTableId)
var virtualWanHubConnectionPropogatedLabels = !empty(virtualNetworkVwanPropagatedLabels) ? virtualNetworkVwanPropagatedLabels : [ 'default' ]

// Telemetry for CARML flip
var enableTelemetryForCarml = !disableTelemetry

// RESOURCES & MODULES

module moveSubscriptionToManagementGroup '../Microsoft.Management/managementGroups/subscriptions/deploy.bicep' = if (subscriptionManagementGroupAssociationEnabled && !empty(subscriptionManagementGroupId)) {
Expand All @@ -129,6 +135,7 @@ module tagSubscription '../../carml/v0.6.0/Microsoft.Resources/tags/deploy.bicep
location: virtualNetworkLocation
onlyUpdate: true
tags: subscriptionTags
enableDefaultTelemetry: enableTelemetryForCarml
}
}

Expand All @@ -139,6 +146,7 @@ module createResourceGroupForLzNetworking '../../carml/v0.6.0/Microsoft.Resource
name: virtualNetworkResourceGroupName
location: virtualNetworkLocation
lock: virtualNetworkResourceGroupLockEnabled ? 'CanNotDelete' : ''
enableDefaultTelemetry: enableTelemetryForCarml
}
}

Expand All @@ -153,6 +161,7 @@ module tagResourceGroup '../../carml/v0.6.0/Microsoft.Resources/tags/deploy.bice
resourceGroupName: virtualNetworkResourceGroupName
onlyUpdate: true
tags: virtualNetworkResourceGroupTags
enableDefaultTelemetry: enableTelemetryForCarml
}
}

Expand All @@ -169,7 +178,7 @@ module createLzVnet '../../carml/v0.6.0/Microsoft.Network/virtualNetworks/deploy
addressPrefixes: virtualNetworkAddressSpace
dnsServers: virtualNetworkDnsServers
ddosProtectionPlanId: virtualNetworkDdosPlanId
virtualNetworkPeerings: (virtualNetworkPeeringEnabled && !empty(hubVirtualNetworkResourceIdChecked)) ? [
virtualNetworkPeerings: (virtualNetworkEnabled && virtualNetworkPeeringEnabled && !empty(hubVirtualNetworkResourceIdChecked) && !empty(virtualNetworkName) && !empty(virtualNetworkAddressSpace) && !empty(virtualNetworkLocation) && !empty(virtualNetworkResourceGroupName)) ? [
{
allowForwardedTraffic: true
allowVirtualNetworkAccess: true
Expand All @@ -183,10 +192,11 @@ module createLzVnet '../../carml/v0.6.0/Microsoft.Network/virtualNetworks/deploy
remotePeeringUseRemoteGateways: false
}
] : []
enableDefaultTelemetry: enableTelemetryForCarml
}
}

module createLzVirtualWanConnection '../../carml/v0.6.0/Microsoft.Network/virtualHubs/hubVirtualNetworkConnections/deploy.bicep' = if (virtualNetworkEnabled && virtualNetworkPeeringEnabled && !empty(virtualHubResourceIdChecked)) {
module createLzVirtualWanConnection '../../carml/v0.6.0/Microsoft.Network/virtualHubs/hubVirtualNetworkConnections/deploy.bicep' = if (virtualNetworkEnabled && virtualNetworkPeeringEnabled && !empty(virtualHubResourceIdChecked) && !empty(virtualNetworkName) && !empty(virtualNetworkAddressSpace) && !empty(virtualNetworkLocation) && !empty(virtualNetworkResourceGroupName) && !empty(virtualWanHubResourceGroupName) && !empty(virtualWanHubSubscriptionId)) {
dependsOn: [
createResourceGroupForLzNetworking
]
Expand All @@ -195,7 +205,7 @@ module createLzVirtualWanConnection '../../carml/v0.6.0/Microsoft.Network/virtua
params: {
name: virtualWanHubConnectionName
virtualHubName: virtualWanHubName
remoteVirtualNetworkId: createLzVnet.outputs.resourceId
remoteVirtualNetworkId: '/subscriptions/${subscriptionId}/resourceGroups/${virtualNetworkResourceGroupName}/providers/Microsoft.Network/virtualNetworks/${virtualNetworkName}'
routingConfiguration: {
associatedRouteTable: {
id: virtualWanHubConnectionAssociatedRouteTable
Expand All @@ -205,6 +215,7 @@ module createLzVirtualWanConnection '../../carml/v0.6.0/Microsoft.Network/virtua
labels: virtualWanHubConnectionPropogatedLabels
}
}
enableDefaultTelemetry: enableTelemetryForCarml
}
}

Expand All @@ -219,6 +230,7 @@ module createLzRoleAssignments '../../carml/v0.6.0/Microsoft.Authorization/roleA
roleDefinitionIdOrName: assignment.definition
subscriptionId: subscriptionId
resourceGroupName: (contains(assignment.relativeScope, '/resourceGroups/') ? split(assignment.relativeScope, '/')[2] : '')
enableDefaultTelemetry: enableTelemetryForCarml
}
}]

Expand Down
16 changes: 14 additions & 2 deletions src/self/subResourceWrapper/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ subscriptionManagementGroupAssociationEnabled | No | Whether to move the s
subscriptionManagementGroupId | No | The destination management group ID for the new subscription. Note: Do not supply the display name. The management group ID forms part of the Azure resource ID. e.g., `/providers/Microsoft.Management/managementGroups/{managementGroupId}`.
subscriptionTags | No | An object of tag key/value pairs to be appended to a subscription. NOTE: Tags will only be overwriten if existing tag exists with same key; values provided here win.
virtualNetworkEnabled | No | Whether to create a virtual network or not.
virtualNetworkResourceGroupName | Yes | The name of the resource group to create the virtual network in.
virtualNetworkResourceGroupName | No | The name of the resource group to create the virtual network in.
virtualNetworkResourceGroupLockEnabled | No | Enables the deployment of a `CanNotDelete` resource locks to the virtual networks resource group.
virtualNetworkResourceGroupTags | No | An object of tag key/value pairs to be appended to the Resource Group that the Virtual Network is created in. NOTE: Tags will only be overwriten if existing tag exists with same key; values provided here win.
virtualNetworkLocation | No | The location of the virtual network. Use region shortnames e.g. uksouth, eastus, etc.
Expand All @@ -32,6 +32,7 @@ virtualNetworkVwanPropagatedRouteTablesResourceIds | No | An array of virt
virtualNetworkVwanPropagatedLabels | No | An array of virtual hub route table labels to propogate routes to. If left blank/empty default label will be propogated to only.
roleAssignmentEnabled | No | Whether to create role assignments or not. If true, supply the array of role assignment objects in the parameter called `roleAssignments`.
roleAssignments | No | Supply an array of objects containing the details of the role assignments to create.
disableTelemetry | No | Disable telemetry collection by this module. For more information on the telemetry collected by this module, that is controlled by this parameter, see this page in the wiki: [Telemetry Tracking Using Customer Usage Attribution (PID)](https://github.com/Azure/bicep-lz-vending/wiki/Telemetry)

### subscriptionId

Expand Down Expand Up @@ -69,7 +70,7 @@ Whether to create a virtual network or not.

### virtualNetworkResourceGroupName

![Parameter Setting](https://img.shields.io/badge/parameter-required-orange?style=flat-square)
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)

The name of the resource group to create the virtual network in.

Expand Down Expand Up @@ -179,6 +180,14 @@ Whether to create role assignments or not. If true, supply the array of role ass

Supply an array of objects containing the details of the role assignments to create.

### disableTelemetry

![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)

Disable telemetry collection by this module. For more information on the telemetry collected by this module, that is controlled by this parameter, see this page in the wiki: [Telemetry Tracking Using Customer Usage Attribution (PID)](https://github.com/Azure/bicep-lz-vending/wiki/Telemetry)

- Default value: `False`

## Snippets

### Parameter file
Expand Down Expand Up @@ -256,6 +265,9 @@ Supply an array of objects containing the details of the role assignments to cre
},
"roleAssignments": {
"value": []
},
"disableTelemetry": {
"value": false
}
}
}
Expand Down

0 comments on commit 5414104

Please sign in to comment.