Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
segraef committed Feb 24, 2024
1 parent a20660c commit 9f024a2
Show file tree
Hide file tree
Showing 15 changed files with 357 additions and 57 deletions.
36 changes: 25 additions & 11 deletions avm/res/batch/batch-account/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,30 @@ resource batchAccount_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@
module batchAccount_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.3.1' = [for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-BatchAccount-PrivateEndpoint-${index}'
params: {
privateLinkServiceConnections: [
name: privateEndpoint.?name ?? 'pep-${last(split(batchAccount.id, '/'))}-${privateEndpoint.service}-${index}'
privateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections != true ? [
{
name: name
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(batchAccount.id, '/'))}-${privateEndpoint.service}-${index}'
properties: {
privateLinkServiceId: batchAccount.id
groupIds: [
privateEndpoint.?service ?? 'batchAccount'
privateEndpoint.service
]
}
}
]
name: privateEndpoint.?name ?? 'pep-${last(split(batchAccount.id, '/'))}-${privateEndpoint.?service ?? 'batchAccount'}-${index}'
] : null
manualPrivateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections == true ? [
{
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(batchAccount.id, '/'))}-${privateEndpoint.service}-${index}'
properties: {
privateLinkServiceId: batchAccount.id
groupIds: [
privateEndpoint.service
]
requestMessage: privateEndpoint.?manualConnectionRequestMessage ?? 'Manual approval required.'
}
}
] : null
subnetResourceId: privateEndpoint.subnetResourceId
enableTelemetry: privateEndpoint.?enableTelemetry ?? enableTelemetry
location: privateEndpoint.?location ?? reference(split(privateEndpoint.subnetResourceId, '/subnets/')[0], '2020-06-01', 'Full').location
Expand All @@ -224,7 +236,6 @@ module batchAccount_privateEndpoints 'br/public:avm/res/network/private-endpoint
privateDnsZoneResourceIds: privateEndpoint.?privateDnsZoneResourceIds
roleAssignments: privateEndpoint.?roleAssignments
tags: privateEndpoint.?tags ?? tags
manualPrivateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections
customDnsConfigs: privateEndpoint.?customDnsConfigs
ipConfigurations: privateEndpoint.?ipConfigurations
applicationSecurityGroupResourceIds: privateEndpoint.?applicationSecurityGroupResourceIds
Expand Down Expand Up @@ -339,8 +350,8 @@ type privateEndpointType = {
@description('Optional. The location to deploy the private endpoint to.')
location: string?

@description('Optional. The service (sub-) type to deploy the private endpoint for. For example "vault" or "blob".')
service: string?
@description('Required. The subresource to deploy the private endpoint for. For example "blob", "table", "queue" or "file".')
service: string

@description('Required. Resource ID of the subnet where the endpoint needs to be created.')
subnetResourceId: string
Expand All @@ -351,6 +362,12 @@ type privateEndpointType = {
@description('Optional. The private DNS zone groups to associate the private endpoint with. A DNS zone group can support up to 5 DNS zones.')
privateDnsZoneResourceIds: string[]?

@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.')
manualConnectionRequestMessage: string?

@description('Optional. Custom DNS configurations.')
customDnsConfigs: {
@description('Required. Fqdn that resolves to private endpoint IP address.')
Expand Down Expand Up @@ -393,9 +410,6 @@ type privateEndpointType = {
@description('Optional. Tags to be applied on all resources/resource groups in this deployment.')
tags: object?

@description('Optional. Manual PrivateLink Service Connections.')
manualPrivateLinkServiceConnections: array?

@description('Optional. Enable/Disable usage telemetry for module.')
enableTelemetry: bool?
}[]?
Expand Down
13 changes: 13 additions & 0 deletions avm/res/batch/batch-account/tests/e2e/max/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ module testDeployment '../../../main.bicep' = [for iteration in [ 'init', 'idem'
privateDnsZoneResourceIds: [
nestedDependencies.outputs.privateDNSZoneResourceId
]
service: 'batchAccount'
subnetResourceId: nestedDependencies.outputs.subnetResourceId
tags: {
'hidden-title': 'This is visible in the resource name'
Expand Down Expand Up @@ -124,6 +125,18 @@ module testDeployment '../../../main.bicep' = [for iteration in [ 'init', 'idem'
}
]
}
{
privateDnsZoneResourceIds: [
nestedDependencies.outputs.privateDNSZoneResourceId
]
service: 'nodeManagement'
subnetResourceId: nestedDependencies.outputs.subnetResourceId
tags: {
'hidden-title': 'This is visible in the resource name'
Environment: 'Non-Prod'
Role: 'DeploymentValidation'
}
}
]
networkProfile: {
accountAccess: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module testDeployment '../../../main.bicep' = [for iteration in [ 'init', 'idem'
privateDnsZoneResourceIds: [
nestedDependencies.outputs.privateDNSZoneResourceId
]
service: 'batchAccount'
subnetResourceId: nestedDependencies.outputs.subnetResourceId
}
]
Expand Down
37 changes: 25 additions & 12 deletions avm/res/databricks/workspace/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,30 @@ resource workspace_roleAssignments 'Microsoft.Authorization/roleAssignments@2022
module workspace_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.3.3' = [for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-Databricks-PrivateEndpoint-${index}'
params: {
privateLinkServiceConnections: [
name: privateEndpoint.?name ?? 'pep-${last(split(workspace.id, '/'))}-${privateEndpoint.service}-${index}'
privateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections != true ? [
{
name: name
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(workspace.id, '/'))}-${privateEndpoint.service}-${index}'
properties: {
privateLinkServiceId: workspace.id
groupIds: [
privateEndpoint.?service ?? 'databricks_ui_api'
privateEndpoint.service
]
}
}
]
name: privateEndpoint.?name ?? 'pep-${last(split(workspace.id, '/'))}-${privateEndpoint.?service ?? 'databricks_ui_api'}-${index}'
] : null
manualPrivateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections == true ? [
{
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(workspace.id, '/'))}-${privateEndpoint.service}-${index}'
properties: {
privateLinkServiceId: workspace.id
groupIds: [
privateEndpoint.service
]
requestMessage: privateEndpoint.?manualConnectionRequestMessage ?? 'Manual approval required.'
}
}
] : null
subnetResourceId: privateEndpoint.subnetResourceId
enableTelemetry: privateEndpoint.?enableTelemetry ?? enableTelemetry
location: privateEndpoint.?location ?? reference(split(privateEndpoint.subnetResourceId, '/subnets/')[0], '2020-06-01', 'Full').location
Expand All @@ -310,7 +322,6 @@ module workspace_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.
privateDnsZoneResourceIds: privateEndpoint.?privateDnsZoneResourceIds
roleAssignments: privateEndpoint.?roleAssignments
tags: privateEndpoint.?tags ?? tags
manualPrivateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections
customDnsConfigs: privateEndpoint.?customDnsConfigs
ipConfigurations: privateEndpoint.?ipConfigurations
applicationSecurityGroupResourceIds: privateEndpoint.?applicationSecurityGroupResourceIds
Expand Down Expand Up @@ -361,15 +372,14 @@ type lockType = {
}?

type privateEndpointType = {

@description('Optional. The name of the private endpoint.')
name: string?

@description('Optional. The location to deploy the private endpoint to.')
location: string?

@description('Optional. The service (sub-) type to deploy the private endpoint for. For example "vault" or "blob".')
service: string?
@description('Required. The subresource to deploy the private endpoint for. For example "blob", "table", "queue" or "file".')
service: string

@description('Required. Resource ID of the subnet where the endpoint needs to be created.')
subnetResourceId: string
Expand All @@ -380,6 +390,12 @@ type privateEndpointType = {
@description('Optional. The private DNS zone groups to associate the private endpoint with. A DNS zone group can support up to 5 DNS zones.')
privateDnsZoneResourceIds: string[]?

@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.')
manualConnectionRequestMessage: string?

@description('Optional. Custom DNS configurations.')
customDnsConfigs: {
@description('Required. Fqdn that resolves to private endpoint IP address.')
Expand Down Expand Up @@ -422,9 +438,6 @@ type privateEndpointType = {
@description('Optional. Tags to be applied on all resources/resource groups in this deployment.')
tags: object?

@description('Optional. Manual PrivateLink Service Connections.')
manualPrivateLinkServiceConnections: array?

@description('Optional. Enable/Disable usage telemetry for module.')
enableTelemetry: bool?
}[]?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ resource keyPermissions 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid('msi-${keyVault::key.id}-${location}-${managedIdentity.id}-Key-Key-Vault-Crypto-User-RoleAssignment')
scope: keyVault::key
properties: {
principalId: '711330f9-cfad-4b10-a462-d82faa92027d' // AzureDatabricks Enterprise Application Object Id (Note: this is tenant specific)
principalId: '09ef9f59-e7b6-422e-84e4-508cfc8d64e7' // '711330f9-cfad-4b10-a462-d82faa92027d' // AzureDatabricks Enterprise Application Object Id (Note: this is tenant specific)
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '12338af0-0e69-4776-bea7-57ae8d297424') // Key Vault Crypto User
principalType: 'ServicePrincipal'
}
Expand Down
8 changes: 8 additions & 0 deletions avm/res/databricks/workspace/tests/e2e/max/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,20 @@ module testDeployment '../../../main.bicep' = [for iteration in [ 'init', 'idem'
privateDnsZoneResourceIds: [
nestedDependencies.outputs.privateDNSZoneResourceId
]
service: 'databricks_ui_api'
subnetResourceId: nestedDependencies.outputs.defaultSubnetResourceId
tags: {
Environment: 'Non-Prod'
Role: 'DeploymentValidation'
}
}
{
privateDnsZoneResourceIds: [
nestedDependencies.outputs.privateDNSZoneResourceId
]
subnetResourceId: nestedDependencies.outputs.defaultSubnetResourceId
service: 'browser_authentication'
}
]
managedResourceGroupResourceId: '${subscription().id}/resourceGroups/rg-${resourceGroupName}-managed'
requireInfrastructureEncryption: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ resource keyPermissions 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid('msi-${keyVault::key.id}-${location}-${managedIdentity.id}-Key-Key-Vault-Crypto-User-RoleAssignment')
scope: keyVault::key
properties: {
principalId: '711330f9-cfad-4b10-a462-d82faa92027d' // AzureDatabricks Enterprise Application Object Id (Note: this is tenant specific)
principalId: '09ef9f59-e7b6-422e-84e4-508cfc8d64e7' // '711330f9-cfad-4b10-a462-d82faa92027d' // AzureDatabricks Enterprise Application Object Id (Note: this is tenant specific)
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '12338af0-0e69-4776-bea7-57ae8d297424') // Key Vault Crypto User
principalType: 'ServicePrincipal'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ module testDeployment '../../../main.bicep' = [for iteration in [ 'init', 'idem'
privateDnsZoneResourceIds: [
nestedDependencies.outputs.privateDNSZoneResourceId
]
service: 'databricks_ui_api'
subnetResourceId: nestedDependencies.outputs.defaultSubnetResourceId
tags: {
Environment: 'Non-Prod'
Expand Down
34 changes: 24 additions & 10 deletions avm/res/document-db/database-account/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,30 @@ module databaseAccount_gremlinDatabases 'gremlin-database/main.bicep' = [for gre
module databaseAccount_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.3.1' = [for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-databaseAccount-PrivateEndpoint-${index}'
params: {
privateLinkServiceConnections: [
name: privateEndpoint.?name ?? 'pep-${last(split(databaseAccount.id, '/'))}-${privateEndpoint.service}-${index}'
privateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections != true ? [
{
name: name
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(databaseAccount.id, '/'))}-${privateEndpoint.service}-${index}'
properties: {
privateLinkServiceId: databaseAccount.id
groupIds: [
privateEndpoint.?service ?? 'Sql'
privateEndpoint.service
]
}
}
]
name: privateEndpoint.?name ?? 'pep-${last(split(databaseAccount.id, '/'))}-${privateEndpoint.?service ?? 'vault'}-${index}'
] : null
manualPrivateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections == true ? [
{
name: privateEndpoint.?privateLinkServiceConnectionName ?? '${last(split(databaseAccount.id, '/'))}-${privateEndpoint.service}-${index}'
properties: {
privateLinkServiceId: databaseAccount.id
groupIds: [
privateEndpoint.service
]
requestMessage: privateEndpoint.?manualConnectionRequestMessage ?? 'Manual approval required.'
}
}
] : null
subnetResourceId: privateEndpoint.subnetResourceId
enableTelemetry: privateEndpoint.?enableTelemetry ?? enableTelemetry
location: privateEndpoint.?location ?? reference(split(privateEndpoint.subnetResourceId, '/subnets/')[0], '2020-06-01', 'Full').location
Expand All @@ -340,7 +352,6 @@ module databaseAccount_privateEndpoints 'br/public:avm/res/network/private-endpo
privateDnsZoneResourceIds: privateEndpoint.?privateDnsZoneResourceIds
roleAssignments: privateEndpoint.?roleAssignments
tags: privateEndpoint.?tags ?? tags
manualPrivateLinkServiceConnections: privateEndpoint.?manualPrivateLinkServiceConnections
customDnsConfigs: privateEndpoint.?customDnsConfigs
ipConfigurations: privateEndpoint.?ipConfigurations
applicationSecurityGroupResourceIds: privateEndpoint.?applicationSecurityGroupResourceIds
Expand Down Expand Up @@ -413,7 +424,7 @@ type privateEndpointType = {
@description('Optional. The location to deploy the private endpoint to.')
location: string?

@description('Required. The service (sub-) type to deploy the private endpoint for. For example "vault" or "blob".')
@description('Required. The subresource to deploy the private endpoint for. For example "blob", "table", "queue" or "file".')
service: string

@description('Required. Resource ID of the subnet where the endpoint needs to be created.')
Expand All @@ -425,6 +436,12 @@ type privateEndpointType = {
@description('Optional. The private DNS zone groups to associate the private endpoint with. A DNS zone group can support up to 5 DNS zones.')
privateDnsZoneResourceIds: string[]?

@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.')
manualConnectionRequestMessage: string?

@description('Optional. Custom DNS configurations.')
customDnsConfigs: {
@description('Required. Fqdn that resolves to private endpoint ip address.')
Expand Down Expand Up @@ -467,9 +484,6 @@ type privateEndpointType = {
@description('Optional. Tags to be applied on all resources/resource groups in this deployment.')
tags: object?

@description('Optional. Manual PrivateLink Service Connections.')
manualPrivateLinkServiceConnections: array?

@description('Optional. Enable/Disable usage telemetry for module.')
enableTelemetry: bool?
}[]?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@description('Optional. The location to deploy to.')
param location string = resourceGroup().location

@description('Required. The name of the Managed Identity to create.')
param managedIdentityName string

@description('Required. The name of the Virtual Network to create.')
param virtualNetworkName string

var addressPrefix = '10.0.0.0/16'

resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: managedIdentityName
location: location
}

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2023-04-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
addressPrefix
]
}
subnets: [
{
name: 'defaultSubnet'
properties: {
addressPrefix: cidrSubnet(addressPrefix, 16, 0)
}
}
]
}
}

resource privateDNSZone 'Microsoft.Network/privateDnsZones@2020-06-01' = {
name: 'privatelink.documents.azure.com'
location: 'global'

resource virtualNetworkLinks 'virtualNetworkLinks@2020-06-01' = {
name: '${virtualNetwork.name}-vnetlink'
location: 'global'
properties: {
virtualNetwork: {
id: virtualNetwork.id
}
registrationEnabled: false
}
}
}

@description('The principal ID of the created Managed Identity.')
output managedIdentityPrincipalId string = managedIdentity.properties.principalId

@description('The resource ID of the created Managed Identity.')
output managedIdentityResourceId string = managedIdentity.id

@description('The resource ID of the created Virtual Network Subnet.')
output subnetResourceId string = virtualNetwork.properties.subnets[0].id

@description('The resource ID of the created Private DNS Zone.')
output privateDNSZoneResourceId string = privateDNSZone.id
Loading

0 comments on commit 9f024a2

Please sign in to comment.