Skip to content

Bicep >=v0.38.3 breaks allowed policyDefinitions scope when using "existing" #18166

@gXkch

Description

@gXkch

Bicep version
>=0.38.3

Describe the bug
Microsoft.Authorization/policyDefinitions with 'existing' cannot use tenant scope anymore since version 0.38.3.

To Reproduce
Steps to reproduce the behavior:

This template is used to get existing builtin policy definitions as they exist on the tenant level:

targetScope = 'managementGroup'

var input array = [
  {policyDefinitionId: '0a914e76-4921-4c19-b460-a2d36003525a'}
]

// Get all builtin policies as defined in the input parameter
resource builtin 'Microsoft.Authorization/policyDefinitions@2023-04-01' existing = [for policy in input: {
  scope: tenant()
  name: policy.policyDefinitionId
}]

When building this template with >=0.38.3, this throws an error: Error BCP135: Scope "tenant" is not valid for this resource type. Permitted scopes: "managementGroup", "subscription". [https://aka.ms/bicep/core-diagnostics#BCP135]

Additional context
This simply worked on earlier versions. I built the template with 0.37.4 and got no errors.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions