Skip to content

Commit

Permalink
fix: Bicep - Updated formatting and fixed outdated descriptors (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSehr authored Feb 4, 2024
1 parent 5ad765f commit 261ca6c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 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 exampleResoruce 'Example.Resource/example@2023-01-31' = {
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 @@ -39,7 +39,7 @@ type diagnosticSettingType = {
@description('Optional. The diagnostic settings of the service.')
param diagnosticSettings diagnosticSettingType

resource exampleResourceDiagnosticSettings '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 @@ -62,5 +62,5 @@ resource exampleResourceDiagnosticSettings 'Microsoft.Insights/diagnosticSetting
marketplacePartnerId: diagnosticSetting.?marketplacePartnerResourceId
logAnalyticsDestinationType: diagnosticSetting.?logAnalyticsDestinationType
}
scope: exampleResource
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 exampleResourceLock '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: exampleResource
scope: <singularMainResourceType>
}
6 changes: 3 additions & 3 deletions docs/static/includes/interfaces/int.mi.udt.schema.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ var identity = !empty(managedIdentities) ? {
userAssignedIdentities: !empty(formattedUserAssignedIdentities) ? formattedUserAssignedIdentities : null
} : null

resource exampleResource 'Example.Resource/example@2023-01-31' = {
name: 'exampleResource'
resource <singularMainResourceType> '<providerNamespace>/<resourceType>@<apiVersion>' = {
name: name
identity: identity
properties: {
... // other properties
}
}

@description('The principal ID of the system assigned identity.')
output systemAssignedPrincipalId string = exampleResource.?identity.?principalId ?? ''
output systemAssignedPrincipalId string = <singularMainResourceType>.?identity.?principalId ?? ''
10 changes: 5 additions & 5 deletions docs/static/includes/interfaces/int.pe.udt.schema1.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type privateEndpointType = {
@description('Optional. Specify the type of lock.')
lock: lockType

@description('Optional. Array of role assignment objects that contain the \'roleDefinitionIdOrName\' and \'principalId\' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.')
@description('Optional. Array of role assignments to create.')
roleAssignments: roleAssignmentType

@description('Optional. Tags to be applied on all resources/resource groups in this deployment.')
Expand All @@ -71,22 +71,22 @@ 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 <exampleResource>PrivateEndpoint 'br/public:avm/res/network/private-endpoint:X.Y.Z' = [for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-<exampleResource>-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)
privateLinkServiceConnections: [
{
name: name
properties: {
privateLinkServiceId: <exampleResource>.id
privateLinkServiceId: <singularMainResourceType>.id
groupIds: [
privateEndpoint.?service ?? '<defaultServiceName>'
]
}
}
]
name: privateEndpoint.?name ?? 'pep-${last(split(<exampleResource>.id, '/'))}-${privateEndpoint.?service ?? '<defaultServiceName>'}-${index}'
name: privateEndpoint.?name ?? 'pep-${last(split(<singularMainResourceType>.id, '/'))}-${privateEndpoint.?service ?? '<defaultServiceName>'}-${index}'
subnetResourceId: privateEndpoint.subnetResourceId
enableTelemetry: privateEndpoint.?enableTelemetry ?? enableTelemetry
location: privateEndpoint.?location ?? reference(split(privateEndpoint.subnetResourceId, '/subnets/')[0], '2020-06-01', 'Full').location
Expand Down
10 changes: 5 additions & 5 deletions docs/static/includes/interfaces/int.pe.udt.schema2.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type privateEndpointType = {
@description('Optional. Specify the type of lock.')
lock: lockType

@description('Optional. Array of role assignment objects that contain the \'roleDefinitionIdOrName\' and \'principalId\' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.')
@description('Optional. Array of role assignments to create.')
roleAssignments: roleAssignmentType

@description('Optional. Tags to be applied on all resources/resource groups in this deployment.')
Expand All @@ -71,22 +71,22 @@ 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 <exampleResource>PrivateEndpoint 'br/public:avm/res/network/private-endpoint:X.Y.Z' = [for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-<exampleResource>-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)
privateLinkServiceConnections: [
{
name: name
properties: {
privateLinkServiceId: <exampleResource>.id
privateLinkServiceId: <singularMainResourceType>.id
groupIds: [
privateEndpoint.service
]
}
}
]
name: privateEndpoint.?name ?? 'pep-${last(split(<exampleResourceSymbolicName>.id, '/'))}-${privateEndpoint.?service ?? privateEndpoint.service}-${index}'
name: privateEndpoint.?name ?? 'pep-${last(split(<singularMainResourceType>.id, '/'))}-${privateEndpoint.?service ?? privateEndpoint.service}-${index}'
subnetResourceId: privateEndpoint.subnetResourceId
enableTelemetry: privateEndpoint.?enableTelemetry ?? enableTelemetry
location: privateEndpoint.?location ?? reference(split(privateEndpoint.subnetResourceId, '/subnets/')[0], '2020-06-01', 'Full').location
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 exampleResourceRoleAssignments 'Microsoft.Authorization/roleAssignments@2022-04-01' = [for (roleAssignment, index) in (roleAssignments ?? []): {
name: guid(exampleResource.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 exampleResourceRoleAssignments 'Microsoft.Authorization/roleAssignments
conditionVersion: !empty(roleAssignment.?condition) ? (roleAssignment.?conditionVersion ?? '2.0') : null // Must only be set if condtion is set
delegatedManagedIdentityResourceId: roleAssignment.?delegatedManagedIdentityResourceId
}
scope: exampleResource
scope: <singularMainResourceType>
}]

0 comments on commit 261ca6c

Please sign in to comment.