Skip to content

Commit

Permalink
Added PE draft
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSehr committed Aug 4, 2023
1 parent 850c467 commit 04d7935
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,60 @@ 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@2022-01-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
addressPrefix
]
}
subnets: [
{
name: 'defaultSubnet'
properties: {
addressPrefix: addressPrefix
}
}
]
}
}

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 privateDNSResourceId string = privateDNSZone.id
16 changes: 16 additions & 0 deletions modules/document-db/database-accounts/.test/sqldb/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module nestedDependencies 'dependencies.bicep' = {
name: '${uniqueString(deployment().name, location)}-nestedDependencies'
params: {
managedIdentityName: 'dep-${namePrefix}-msi-${serviceShort}'
virtualNetworkName: 'dep-${namePrefix}-vnet-${serviceShort}'
}
}

Expand Down Expand Up @@ -81,6 +82,21 @@ module testDeployment '../../main.bicep' = {
diagnosticEventHubName: diagnosticDependencies.outputs.eventHubNamespaceEventHubName
diagnosticLogsRetentionInDays: 7
location: location
privateEndpoints: [
{
privateDnsZoneGroup: {
privateDNSResourceIds: [
nestedDependencies.outputs.privateDNSResourceId
]
}
service: 'Sql'
subnetResourceId: nestedDependencies.outputs.subnetResourceId
tags: {
Environment: 'Non-Prod'
Role: 'DeploymentValidation'
}
}
]
roleAssignments: [
{
roleDefinitionIdOrName: 'Reader'
Expand Down
26 changes: 26 additions & 0 deletions modules/document-db/database-accounts/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ param backupRetentionIntervalInHours int = 8
@description('Optional. Enum to indicate type of backup residency. Only applies to periodic backup type.')
param backupStorageRedundancy string = 'Local'

@description('Optional. Configuration details for private endpoints. For security reasons, it is recommended to use private endpoints whenever possible.')
param privateEndpoints array = []

var diagnosticsLogsSpecified = [for category in filter(diagnosticLogCategoriesToEnable, item => item != 'allLogs' && item != ''): {
category: category
enabled: true
Expand Down Expand Up @@ -365,6 +368,29 @@ module databaseAccount_gremlinDatabases 'gremlin-databases/main.bicep' = [for gr
}
}]

module databaseAccount_privateEndpoints '../../network/private-endpoints/main.bicep' = [for (privateEndpoint, index) in privateEndpoints: {
name: '${uniqueString(deployment().name, location)}-CosmosDB-PrivateEndpoint-${index}'
params: {
groupIds: [
privateEndpoint.service
]
name: contains(privateEndpoint, 'name') ? privateEndpoint.name : 'pe-${last(split(databaseAccount.id, '/'))}-${privateEndpoint.service}-${index}'
serviceResourceId: databaseAccount.id
subnetResourceId: privateEndpoint.subnetResourceId
enableDefaultTelemetry: enableReferencedModulesTelemetry
location: reference(split(privateEndpoint.subnetResourceId, '/subnets/')[0], '2020-06-01', 'Full').location
lock: contains(privateEndpoint, 'lock') ? privateEndpoint.lock : lock
privateDnsZoneGroup: contains(privateEndpoint, 'privateDnsZoneGroup') ? privateEndpoint.privateDnsZoneGroup : {}
roleAssignments: contains(privateEndpoint, 'roleAssignments') ? privateEndpoint.roleAssignments : []
tags: contains(privateEndpoint, 'tags') ? privateEndpoint.tags : {}
manualPrivateLinkServiceConnections: contains(privateEndpoint, 'manualPrivateLinkServiceConnections') ? privateEndpoint.manualPrivateLinkServiceConnections : []
customDnsConfigs: contains(privateEndpoint, 'customDnsConfigs') ? privateEndpoint.customDnsConfigs : []
ipConfigurations: contains(privateEndpoint, 'ipConfigurations') ? privateEndpoint.ipConfigurations : []
applicationSecurityGroups: contains(privateEndpoint, 'applicationSecurityGroups') ? privateEndpoint.applicationSecurityGroups : []
customNetworkInterfaceName: contains(privateEndpoint, 'customNetworkInterfaceName') ? privateEndpoint.customNetworkInterfaceName : ''
}
}]

@description('The name of the database account.')
output name string = databaseAccount.name

Expand Down

0 comments on commit 04d7935

Please sign in to comment.