Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use endpoint module for cosmosdb #838

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dev-infrastructure/modules/private-endpoint.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ param location string
@allowed([
'eventgrid'
'keyvault'
'cosmosdb'
])
param serviceType string

@description('The group id of the private endpoint service')
@allowed([
'topicspace'
'vault'
'Sql'
])
param groupId string

Expand All @@ -30,6 +32,9 @@ var endpointConfig = {
keyvault: {
vault: 'privatelink.vaultcore.azure.net'
}
cosmosdb: {
Sql: 'privatelink.documents.azure.com'
}
}

resource eventGridPrivateEndpointDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' = {
Expand Down
62 changes: 9 additions & 53 deletions dev-infrastructure/modules/rp-cosmos.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -82,59 +82,15 @@ resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2023-11-15' = {
}
}

resource cosmosDbPrivateEndpoint 'Microsoft.Network/privateEndpoints@2023-09-01' = {
name: '${name}-private-endpoint'
location: location
properties: {
privateLinkServiceConnections: [
{
name: '${name}-private-endpoint'
properties: {
privateLinkServiceId: cosmosDbAccount.id
groupIds: [
'Sql'
]
}
}
]
subnet: {
id: aksNodeSubnetId
}
}
}

resource cosmosPrivateEndpointDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' = {
// https://github.com/Azure/bicep/issues/12482
// There is no environments().suffixes constant for this
name: 'privatelink.documents.azure.com'
location: 'global'
properties: {}
}

resource cosmosPrivateEndpointDnsZoneLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = {
parent: cosmosPrivateEndpointDnsZone
name: 'link'
location: 'global'
properties: {
registrationEnabled: false
virtualNetwork: {
id: vnetId
}
}
}

resource cosmosPrivateEndpointDnsGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2023-09-01' = {
parent: cosmosDbPrivateEndpoint
name: '${name}-dns-group'
properties: {
privateDnsZoneConfigs: [
{
name: 'config1'
properties: {
privateDnsZoneId: cosmosPrivateEndpointDnsZone.id
}
}
]
module serviceCosmosdbPrivateEndpoint '../modules/private-endpoint.bicep' = {
name: '${deployment().name}-svcs-kv-pe'
params: {
location: location
subnetIds: [aksNodeSubnetId]
vnetId: vnetId
privateLinkServiceId: cosmosDbAccount.id
serviceType: 'cosmosdb'
groupId: 'Sql'
}
}

Expand Down