Open VeraBE opened 2 years ago
Hi all have the same issue but then when working from bicep.
See the below sample which is one of my modules where in we use the metadata keyword to be able to save info on the template:
`metadata info = { name: 'RBAC Module' description: 'This module deploys a Role Based Access assignments' version: '1.0.0' author: 'Maik van der Gaag' }
param principalId string param roleDefinitionResourceId string
@description('This is the built-in Contributor role. See https://docs.microsoft.com/azure/role-based-access-control/built-in-roles#contributor') resource roleDefinition 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = { scope: subscription() name: roleDefinitionResourceId }
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = { name: guid(resourceGroup().id, principalId, roleDefinition.id) properties: { roleDefinitionId: roleDefinition.id principalId: principalId principalType: 'ServicePrincipal' } scope: resourceGroup() }`
When we analyze this with '.\TemplateAnalyzer.exe analyze-template D:\source\rbac.bicep -v'
We get the following errors:
Removing the metadata section solved the problem.
Thanks for reporting this @maikvandergaag. This looks like it's actually a different issue specific to Bicep, maybe a Bicep compiler version issue. Can you please create a new bug report with the above? @nonik0 FYI.
Describe the bug
A user reported that the tool was throwing a TemplateAnalyzerException on a valid ARM template. The error logged to the console output:
The template parameter
name
in the template has a default value of[format('{0}-{1}-{2}', replace(parameters('addressSpace')[0], '/', '-'), split(subscription().displayName, '.')[0], split(subscription().displayName, '.')[1])]
, and for our analysis we don’t have access to the subscription information, so instead of using the realdisplayName
, we use a placeholder value, that doesn’t have a dot, that’s whysplit(subscription().displayName, '.')[1]
is an out of bounds accessExpected behavior
The template should be analyzed
Reproduction Steps
Analyze a template that anywhere uses an expression like
split(subscription().displayName, '.')[1]
Environment
No response