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

Generate uniqueData for Private Link resources in an idempotent manner #748

Merged
Merged
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
20 changes: 10 additions & 10 deletions src/bicep/modules/private-link.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Licensed under the MIT License.
*/

@description('The name of the resource the private endpoint is being created for')
param logAnalyticsWorkspaceName string
param logAnalyticsWorkspaceName string

@description('The resource id of the resoure the private endpoint is being created for')
param logAnalyticsWorkspaceResourceId string
param logAnalyticsWorkspaceResourceId string

@description('The name of the subnet in the virtual network where the private endpoint will be placed')
param privateEndpointSubnetName string
Expand All @@ -19,7 +19,7 @@ param privateEndpointVnetName string
param tags object

@description('Data used to append to resources to ensure uniqueness')
param uniqueData string = substring(newGuid(), 0, 8)
param uniqueData string = substring(uniqueString(subscription().subscriptionId, deployment().name), 0, 8)

@description('The name of the the resource group where the virtual network exists')
param vnetResourceGroup string = resourceGroup().name
Expand All @@ -45,7 +45,7 @@ param agentsvcPrivateDnsZoneId string
@description('Azure Blob Storage Private DNS Zone resource id')
param storagePrivateDnsZoneId string

var privateLinkConnectionName = take('plconn${logAnalyticsWorkspaceName}${uniqueData}', 80)
var privateLinkConnectionName = take('plconn${logAnalyticsWorkspaceName}${uniqueData}', 80)
var privateLinkEndpointName = take('pl${logAnalyticsWorkspaceName}${uniqueData}', 80)
var privateLinkScopeName = take('plscope${logAnalyticsWorkspaceName}${uniqueData}', 80)
var privateLinkScopeResourceName = take('plscres${logAnalyticsWorkspaceName}${uniqueData}', 80)
Expand All @@ -56,17 +56,17 @@ resource globalPrivateLinkScope 'microsoft.insights/privateLinkScopes@2019-10-17
properties: {}
}

resource logAnalyticsWorkspacePrivateLinkScope 'microsoft.insights/privateLinkScopes/scopedResources@2019-10-17-preview' = {
resource logAnalyticsWorkspacePrivateLinkScope 'microsoft.insights/privateLinkScopes/scopedResources@2019-10-17-preview' = {
name: '${privateLinkScopeName}/${privateLinkScopeResourceName}'
properties: {
linkedResourceId: logAnalyticsWorkspaceResourceId
}
dependsOn: [
globalPrivateLinkScope
globalPrivateLinkScope
]
}

resource subnetPrivateEndpoint 'Microsoft.Network/privateEndpoints@2020-07-01' = {
resource subnetPrivateEndpoint 'Microsoft.Network/privateEndpoints@2020-07-01' = {
name: privateLinkEndpointName
location: location
tags: tags
Expand All @@ -76,7 +76,7 @@ resource subnetPrivateEndpoint 'Microsoft.Network/privateEndpoints@2020-07-01'
}
privateLinkServiceConnections: [
{
name: privateLinkConnectionName
name: privateLinkConnectionName
properties: {
privateLinkServiceId: globalPrivateLinkScope.id
groupIds: [
Expand All @@ -87,7 +87,7 @@ resource subnetPrivateEndpoint 'Microsoft.Network/privateEndpoints@2020-07-01'
]
}
dependsOn: [
logAnalyticsWorkspacePrivateLinkScope
logAnalyticsWorkspacePrivateLinkScope
]
}

Expand Down Expand Up @@ -128,6 +128,6 @@ resource dnsZonePrivateLinkEndpoint 'Microsoft.Network/privateEndpoints/privateD
]
}
dependsOn: [
subnetPrivateEndpoint
subnetPrivateEndpoint
]
}