Skip to content

Commit

Permalink
fix: Fixed prefix & suffix for Bicep schemas as they were unintendedl…
Browse files Browse the repository at this point in the history
…y interpreted in some cases (#689)
  • Loading branch information
AlexanderSehr authored Feb 27, 2024
1 parent 22fa3b5 commit 4f6c132
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions docs/static/includes/interfaces/int.cmk.udt.schema.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ resource cMKUserAssignedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentiti
scope: resourceGroup(split((customerManagedKey.?userAssignedIdentityResourceId ?? '//'), '/')[2], split((customerManagedKey.?userAssignedIdentityResourceId ?? '////'), '/')[4])
}

resource <singularMainResourceType> '<providerNamespace>/<resourceType>@<apiVersion>' = {
name: '<exampleResource>'
resource >singularMainResourceType< '>providerNamespace</>resourceType<@>apiVersion<' = {
name: '>exampleResource<'
properties: {
... // other properties
encryption: !empty(customerManagedKey) ? {
Expand Down
4 changes: 2 additions & 2 deletions docs/static/includes/interfaces/int.diag.udt.schema.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type diagnosticSettingType = {
@description('Optional. The diagnostic settings of the service.')
param diagnosticSettings diagnosticSettingType

resource <singularMainResourceType>_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = [for (diagnosticSetting, index) in (diagnosticSettings ?? []): {
resource >singularMainResourceType<_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = [for (diagnosticSetting, index) in (diagnosticSettings ?? []): {
name: diagnosticSetting.?name ?? '${name}-diagnosticSettings'
properties: {
storageAccountId: diagnosticSetting.?storageAccountResourceId
Expand All @@ -65,5 +65,5 @@ resource <singularMainResourceType>_diagnosticSettings 'Microsoft.Insights/diagn
marketplacePartnerId: diagnosticSetting.?marketplacePartnerResourceId
logAnalyticsDestinationType: diagnosticSetting.?logAnalyticsDestinationType
}
scope: <singularMainResourceType>
scope: >singularMainResourceType<
}]
4 changes: 2 additions & 2 deletions docs/static/includes/interfaces/int.locks.udt.schema.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ type lockType = {
@description('Optional. The lock settings of the service.')
param lock lockType

resource <singularMainResourceType>_lock 'Microsoft.Authorization/locks@2020-05-01' = if (!empty(lock ?? {}) && lock.?kind != 'None') {
resource >singularMainResourceType<_lock 'Microsoft.Authorization/locks@2020-05-01' = if (!empty(lock ?? {}) && lock.?kind != 'None') {
name: lock.?name ?? 'lock-${name}'
properties: {
level: lock.?kind ?? ''
notes: lock.?kind == 'CanNotDelete' ? 'Cannot delete resource or child resources.' : 'Cannot delete or modify the resource or child resources.'
}
scope: <singularMainResourceType>
scope: >singularMainResourceType<
}
4 changes: 2 additions & 2 deletions docs/static/includes/interfaces/int.mi.udt.schema.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var identity = !empty(managedIdentities) ? {
userAssignedIdentities: !empty(formattedUserAssignedIdentities) ? formattedUserAssignedIdentities : null
} : null

resource <singularMainResourceType> '<providerNamespace>/<resourceType>@<apiVersion>' = {
resource >singularMainResourceType< '>providerNamespace</>resourceType<@>apiVersion<' = {
name: name
identity: identity
properties: {
Expand All @@ -24,4 +24,4 @@ resource <singularMainResourceType> '<providerNamespace>/<resourceType>@<apiVers
}

@description('The principal ID of the system assigned identity.')
output systemAssignedPrincipalId string = <singularMainResourceType>.?identity.?principalId ?? ''
output systemAssignedPrincipalId string = >singularMainResourceType<.?identity.?principalId ?? ''
19 changes: 10 additions & 9 deletions docs/static/includes/interfaces/int.pe.udt.schema1.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type privateEndpointType = {
@description('Optional. If Manual Private Link Connection is required.')
isManualConnection: bool?

@description('Optional. A message passed to the owner of the remote resource with the manual connection request. Restricted to 140 chars.')
@description('Optional. A message passed to the owner of the remote resource with the manual connection request.')
@maxLength(140)
manualConnectionRequestMessage: string?

@description('Optional. Custom DNS configurations.')
Expand Down Expand Up @@ -73,29 +74,29 @@ type privateEndpointType = {
@description('Optional. Configuration details for private endpoints. For security reasons, it is recommended to use private endpoints whenever possible.')
param privateEndpoints privateEndpointType

module <singularMainResourceType>_privateEndpoints 'br/public:avm/res/network/private-endpoint:X.Y.Z' = [for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-<singularMainResourceType>-PrivateEndpoint-${index}'
module >singularMainResourceType<_privateEndpoints 'br/public:avm/res/network/private-endpoint:X.Y.Z' = [for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}->singularMainResourceType<-PrivateEndpoint-${index}'
params: {
// Variant 1: A default service can be assumed (i.e., for services that only have one private endpoint type)
name: privateEndpoint.?name ?? 'pep-${last(split(<singularMainResourceType>.id, '/'))}-${privateEndpoint.?service ?? <defaultServiceName>}-${index}'
name: privateEndpoint.?name ?? 'pep-${last(split(>singularMainResourceType<.id, '/'))}-${privateEndpoint.?service ?? '>defaultServiceName<'}-${index}'
privateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections != true ? [
{
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(<singularMainResourceType>.id, '/'))}-${privateEndpoint.?service ?? '<defaultServiceName>'}-${index}'
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(>singularMainResourceType<.id, '/'))}-${privateEndpoint.?service ?? '>defaultServiceName<'}-${index}'
properties: {
privateLinkServiceId: <singularMainResourceType>.id
privateLinkServiceId: >singularMainResourceType<.id
groupIds: [
privateEndpoint.?service ?? '<defaultServiceName>'
privateEndpoint.?service ?? '>defaultServiceName<'
]
}
}
] : null
manualPrivateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections == true ? [
{
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(<singularMainResourceType>.id, '/'))}-${privateEndpoint.?service ?? '<defaultServiceName>'}-${index}'
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(>singularMainResourceType<.id, '/'))}-${privateEndpoint.?service ?? '>defaultServiceName<'}-${index}'
properties: {
privateLinkServiceId: workspace.id
groupIds: [
privateEndpoint.?service ?? '<defaultServiceName>'
privateEndpoint.?service ?? '>defaultServiceName<'
]
requestMessage: privateEndpoint.?manualConnectionRequestMessage ?? 'Manual approval required.'
}
Expand Down
15 changes: 8 additions & 7 deletions docs/static/includes/interfaces/int.pe.udt.schema2.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type privateEndpointType = {
@description('Optional. If Manual Private Link Connection is required.')
isManualConnection: bool?

@description('Optional. A message passed to the owner of the remote resource with the manual connection request. Restricted to 140 chars.')
@description('Optional. A message passed to the owner of the remote resource with the manual connection request.')
@maxLength(140)
manualConnectionRequestMessage: string?

@description('Optional. Custom DNS configurations.')
Expand Down Expand Up @@ -73,16 +74,16 @@ type privateEndpointType = {
@description('Optional. Configuration details for private endpoints. For security reasons, it is recommended to use private endpoints whenever possible.')
param privateEndpoints privateEndpointType

module <singularMainResourceType>_privateEndpoints 'br/public:avm/res/network/private-endpoint:X.Y.Z' = [for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-<singularMainResourceType>-PrivateEndpoint-${index}'
module >singularMainResourceType<_privateEndpoints 'br/public:avm/res/network/private-endpoint:X.Y.Z' = [for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}->singularMainResourceType<-PrivateEndpoint-${index}'
params: {
// Variant 2: A default service cannot be assumed (i.e., for services that have more than one private endpoint type, like Storage Account)
name: privateEndpoint.?name ?? 'pep-${last(split(<singularMainResourceType>.id, '/'))}-${privateEndpoint.?service ?? <defaultServiceName>}-${index}'
name: privateEndpoint.?name ?? 'pep-${last(split(>singularMainResourceType>.id, '/'))}-${privateEndpoint.service}-${index}'
privateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections != true ? [
{
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(<singularMainResourceType>.id, '/'))}-${privateEndpoint.service}-${index}'
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(>singularMainResourceType<.id, '/'))}-${privateEndpoint.service}-${index}'
properties: {
privateLinkServiceId: <singularMainResourceType>.id
privateLinkServiceId: >singularMainResourceType<.id
groupIds: [
privateEndpoint.service
]
Expand All @@ -91,7 +92,7 @@ module <singularMainResourceType>_privateEndpoints 'br/public:avm/res/network/pr
] : null
manualPrivateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections == true ? [
{
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(<singularMainResourceType>.id, '/'))}-${privateEndpoint.service}-${index}'
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(>singularMainResourceType<.id, '/'))}-${privateEndpoint.service}-${index}'
properties: {
privateLinkServiceId: workspace.id
groupIds: [
Expand Down
6 changes: 3 additions & 3 deletions docs/static/includes/interfaces/int.rbac.udt.schema.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var builtInRoleNames = {
'User Access Administrator': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')
}

resource <singularMainResourceType>_roleAssignments 'Microsoft.Authorization/roleAssignments@2022-04-01' = [for (roleAssignment, index) in (roleAssignments ?? []): {
name: guid(<singularMainResourceType>.id, roleAssignment.principalId, roleAssignment.roleDefinitionIdOrName)
resource >singularMainResourceType<_roleAssignments 'Microsoft.Authorization/roleAssignments@2022-04-01' = [for (roleAssignment, index) in (roleAssignments ?? []): {
name: guid(>singularMainResourceType<.id, roleAssignment.principalId, roleAssignment.roleDefinitionIdOrName)
properties: {
roleDefinitionId: contains(builtInRoleNames, roleAssignment.roleDefinitionIdOrName) ? builtInRoleNames[roleAssignment.roleDefinitionIdOrName] : contains(roleAssignment.roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/') ? roleAssignment.roleDefinitionIdOrName : subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleAssignment.roleDefinitionIdOrName)
principalId: roleAssignment.principalId
Expand All @@ -44,5 +44,5 @@ resource <singularMainResourceType>_roleAssignments 'Microsoft.Authorization/rol
conditionVersion: !empty(roleAssignment.?condition) ? (roleAssignment.?conditionVersion ?? '2.0') : null // Must only be set if condtion is set
delegatedManagedIdentityResourceId: roleAssignment.?delegatedManagedIdentityResourceId
}
scope: <singularMainResourceType>
scope: >singularMainResourceType<
}]

0 comments on commit 4f6c132

Please sign in to comment.