Skip to content

Commit

Permalink
Add note about #disable-next-line to each usage and FAQ (#167)
Browse files Browse the repository at this point in the history
* changes to fix 153 concerns

* remove incorrect file staged and typo fix in URL

* remove unrequired file
  • Loading branch information
jtracey93 authored Feb 28, 2022
1 parent ffb8043 commit 0e64799
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 16 deletions.
12 changes: 10 additions & 2 deletions docs/wiki/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ Some FAQ questions that relate more to the architecture are based over in the CA
## List of Frequently Asked Questions

- TBC
- [Why are some linter rules disabled via the `#disable-next-line` Bicep function?](#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function)

---

## Questions & Answers
## Questions & Answers

## Why are some linter rules disabled via the `#disable-next-line` Bicep function?

In some of the ALZ-Bicep modules some of linter rules are disabled using the `#disable-next-line` Bicep feature. Today, this is primarily for disabling the [no-loc-expr-outside-params linter rule](https://docs.microsoft.com/azure/azure-resource-manager/bicep/linter-rule-no-loc-expr-outside-params) for the, optional, telemetry module as we want to ensure this telemetry deployment is stored in the same location as specified by the `location` input when deploying the Bicep module, instead of in the same location as specified by `parRegion` or `parLocation` as this may be different from the region targeted by the deployment to ARM.

You may also see it in some location for resources that do not require a region for deployment, like Azure Policies, so instead of making users input an additional parameter for the region, we just use the one that was targeted by the deployment to ARM when the module was deployed.

It is not recommended to disable linter rules when it can be resolved by making changes to the Bicep code. However, in some scenarios, like above, this is necessary.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module modRolesSecurityOperationsRole 'definitions/caf-security-operations-role.

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../CRML/customerUsageAttribution/cuaIdManagementGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(deployment().location)}'
params: {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ resource resVirtualNetworkLink 'Microsoft.Network/privateDnsZones/virtualNetwork

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../CRML/customerUsageAttribution/cuaIdResourceGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(resourceGroup().location)}'
params: {}
}
Expand Down
2 changes: 1 addition & 1 deletion infra-as-code/bicep/modules/logging/logging.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ resource resLogAnalyticsLinkedServiceForAutomationAccount 'Microsoft.Operational

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../CRML/customerUsageAttribution/cuaIdResourceGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(resourceGroup().location)}'
params: {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,11 @@ resource resLandingZonesOnlineMG 'Microsoft.Management/managementGroups@2021-04-

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../CRML/customerUsageAttribution/cuaIdTenant.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(deployment().location)}'
params: {}
}


// Output Management Group IDs
output outTopLevelMGId string = resTopLevelMG.id

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var varCuaid = '98cef979-5a6b-403b-83c7-10c8f04ac9a2'
// Orchestration Module Variables
var varDeploymentNameWrappers = {
basePrefix: 'ALZBicep'
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Policies resources are not deployed to a region, like other resources, but the metadata is stored in a region hence requiring this to keep input parameters reduced. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
baseSuffixTenantAndManagementGroup: '${deployment().location}-${uniqueString(deployment().location, parTopLevelManagementGroupPrefix)}'
}

Expand Down Expand Up @@ -226,7 +226,7 @@ targetScope = 'managementGroup'

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../../../CRML/customerUsageAttribution/cuaIdManagementGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(deployment().location)}'
params: {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ resource resPolicyAssignment 'Microsoft.Authorization/policyAssignments@2020-09-
identity: {
type: varPolicyIdentity
}
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Policies resources are not deployed to a region, like other resources, but the metadata is stored in a region hence requiring this to keep input parameters reduced. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
location: deployment().location
}

Expand Down Expand Up @@ -110,7 +110,7 @@ module modPolicyIdentityRoleAssignmentSubsMany '../../roleAssignments/roleAssign

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../../CRML/customerUsageAttribution/cuaIdManagementGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(deployment().location, parPolicyAssignmentName)}'
params: {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ resource resPolicySetDefinitions 'Microsoft.Authorization/policySetDefinitions@2

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../../CRML/customerUsageAttribution/cuaIdManagementGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(deployment().location)}'
params: {}
}
2 changes: 1 addition & 1 deletion infra-as-code/bicep/modules/publicIp/publicIp.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ resource resPublicIP 'Microsoft.Network/publicIPAddresses@2021-02-01' ={

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../CRML/customerUsageAttribution/cuaIdResourceGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(resourceGroup().location, parPublicIPName)}'
params: {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ resource resRoleAssignment 'Microsoft.Authorization/roleAssignments@2020-08-01-p

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../CRML/customerUsageAttribution/cuaIdManagementGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(deployment().location, parRoleAssignmentNameGuid)}'
params: {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource resSubscriptionPlacement 'Microsoft.Management/managementGroups/subscri

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../CRML/customerUsageAttribution/cuaIdManagementGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(deployment().location)}'
params: {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ resource resVirtualNetworkPeer 'Microsoft.Network/virtualNetworks/virtualNetwork

// Optional Deployment for Customer Usage Attribution
module modCustomerUsageAttribution '../../CRML/customerUsageAttribution/cuaIdResourceGroup.bicep' = if (!parTelemetryOptOut) {
#disable-next-line no-loc-expr-outside-params
#disable-next-line no-loc-expr-outside-params //Only to ensure telemetry data is stored in same location as deployment. See https://github.com/Azure/ALZ-Bicep/wiki/FAQ#why-are-some-linter-rules-disabled-via-the-disable-next-line-bicep-function for more information
name: 'pid-${varCuaid}-${uniqueString(resourceGroup().location)}'
params: {}
}

0 comments on commit 0e64799

Please sign in to comment.