2022-05-19 12:29:59 +03:00
|
|
|
// Global parameters
|
|
|
|
targetScope = 'subscription'
|
|
|
|
|
|
|
|
@description('GUID for Resource Naming')
|
|
|
|
param guid string = newGuid()
|
|
|
|
|
|
|
|
@description('Deployment Location')
|
|
|
|
param location string = deployment().location
|
|
|
|
|
2022-05-26 21:57:45 +03:00
|
|
|
@description('Prefix for Resource Naming')
|
2022-05-28 06:20:28 +03:00
|
|
|
param namePrefix string = 'ipam'
|
2022-05-25 00:56:22 +03:00
|
|
|
|
2022-08-10 11:18:49 +03:00
|
|
|
@description('Azure Cloud Enviroment')
|
|
|
|
param azureCloud string = 'AZURE_PUBLIC'
|
|
|
|
|
2022-08-09 00:36:57 +03:00
|
|
|
@description('Flag to Deploy IPAM as a Function')
|
|
|
|
param deployAsFunc bool = false
|
|
|
|
|
2022-05-24 02:29:13 +03:00
|
|
|
@description('IPAM-UI App Registration Client/App ID')
|
2022-08-30 18:53:51 +03:00
|
|
|
param uiAppId string = '00000000-0000-0000-0000-000000000000'
|
2022-05-24 02:29:13 +03:00
|
|
|
|
|
|
|
@description('IPAM-Engine App Registration Client/App ID')
|
|
|
|
param engineAppId string
|
2022-05-19 12:29:59 +03:00
|
|
|
|
|
|
|
@secure()
|
2022-05-24 02:29:13 +03:00
|
|
|
@description('IPAM-Engine App Registration Client Secret')
|
|
|
|
param engineAppSecret string
|
2022-05-19 12:29:59 +03:00
|
|
|
|
2022-05-25 00:56:22 +03:00
|
|
|
@description('Tags')
|
2022-05-28 06:20:28 +03:00
|
|
|
param tags object = {}
|
2022-05-19 12:29:59 +03:00
|
|
|
|
2022-05-25 00:56:22 +03:00
|
|
|
// Resource naming variables
|
|
|
|
var appServiceName = '${namePrefix}-${uniqueString(guid)}'
|
|
|
|
var appServicePlanName = '${namePrefix}-asp-${uniqueString(guid)}'
|
|
|
|
var cosmosAccountName = '${namePrefix}-dbacct-${uniqueString(guid)}'
|
2022-08-10 02:09:45 +03:00
|
|
|
var cosmosContainerName = '${namePrefix}-ctr'
|
|
|
|
var cosmosDatabaseName = '${namePrefix}-db'
|
2022-05-25 00:56:22 +03:00
|
|
|
var keyVaultName = '${namePrefix}-kv-${uniqueString(guid)}'
|
2022-08-10 02:09:45 +03:00
|
|
|
var workspaceName = '${namePrefix}-law-${uniqueString(guid)}'
|
2022-05-25 00:56:22 +03:00
|
|
|
var managedIdentityName = '${namePrefix}-mi-${uniqueString(guid)}'
|
|
|
|
var resourceGroupName = '${namePrefix}-rg-${uniqueString(guid)}'
|
|
|
|
var storageName = '${namePrefix}stg${uniqueString(guid)}'
|
2022-05-19 12:29:59 +03:00
|
|
|
|
|
|
|
|
2022-05-24 02:29:13 +03:00
|
|
|
// Resource Group
|
2022-05-19 12:29:59 +03:00
|
|
|
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
|
|
|
|
location: location
|
2022-05-25 00:56:22 +03:00
|
|
|
name: resourceGroupName
|
|
|
|
tags: tags
|
2022-05-19 12:29:59 +03:00
|
|
|
}
|
|
|
|
|
2022-08-10 02:09:45 +03:00
|
|
|
// Log Analytics Workspace
|
|
|
|
module logAnalyticsWorkspace 'logAnalyticsWorkspace.bicep' ={
|
|
|
|
name: 'logAnalyticsWorkspaceModule'
|
|
|
|
scope: resourceGroup
|
|
|
|
params: {
|
|
|
|
workspaceName: workspaceName
|
|
|
|
location: location
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-24 02:29:13 +03:00
|
|
|
// Managed Identity for Secure Access to KeyVault
|
2022-05-19 12:29:59 +03:00
|
|
|
module managedIdentity 'managedIdentity.bicep' = {
|
|
|
|
name: 'managedIdentityModule'
|
|
|
|
scope: resourceGroup
|
|
|
|
params: {
|
|
|
|
managedIdentityName: managedIdentityName
|
|
|
|
location: location
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-24 02:29:13 +03:00
|
|
|
// KeyVault for Secure Values
|
2022-08-09 00:36:57 +03:00
|
|
|
module keyVault 'keyVault.bicep' = {
|
2022-05-19 12:29:59 +03:00
|
|
|
name: 'keyVaultModule'
|
|
|
|
scope: resourceGroup
|
|
|
|
params: {
|
|
|
|
keyVaultName: keyVaultName
|
|
|
|
location: location
|
|
|
|
principalId: managedIdentity.outputs.principalId
|
2022-05-24 02:29:13 +03:00
|
|
|
uiAppId: uiAppId
|
|
|
|
engineAppId: engineAppId
|
|
|
|
engineAppSecret: engineAppSecret
|
2022-08-10 02:09:45 +03:00
|
|
|
workspaceId: logAnalyticsWorkspace.outputs.workspaceId
|
2022-05-19 12:29:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-24 02:29:13 +03:00
|
|
|
// Cosmos DB for IPAM Database
|
2022-05-19 12:29:59 +03:00
|
|
|
module cosmos 'cosmos.bicep' = {
|
|
|
|
name: 'cosmosModule'
|
|
|
|
scope: resourceGroup
|
|
|
|
params: {
|
|
|
|
location: location
|
|
|
|
cosmosAccountName: cosmosAccountName
|
2022-08-10 02:09:45 +03:00
|
|
|
cosmosContainerName: cosmosContainerName
|
|
|
|
cosmosDatabaseName: cosmosDatabaseName
|
2022-05-19 12:29:59 +03:00
|
|
|
keyVaultName: keyVault.outputs.keyVaultName
|
2022-08-10 02:09:45 +03:00
|
|
|
workspaceId: logAnalyticsWorkspace.outputs.workspaceId
|
2022-05-19 12:29:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-24 02:29:13 +03:00
|
|
|
// Storage Account for Nginx Config
|
2022-05-20 01:05:43 +03:00
|
|
|
module storageAccount 'storageAccount.bicep' = {
|
|
|
|
scope: resourceGroup
|
|
|
|
name: 'storageAccountModule'
|
|
|
|
params: {
|
|
|
|
location: location
|
|
|
|
storageAccountName: storageName
|
|
|
|
principalId: managedIdentity.outputs.principalId
|
|
|
|
managedIdentityId: managedIdentity.outputs.id
|
2022-08-10 02:09:45 +03:00
|
|
|
workspaceId: logAnalyticsWorkspace.outputs.workspaceId
|
2022-08-09 00:36:57 +03:00
|
|
|
deployAsFunc: deployAsFunc
|
2022-05-20 01:05:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-24 02:29:13 +03:00
|
|
|
// App Service w/ Docker Compose + CI
|
2022-08-09 00:36:57 +03:00
|
|
|
module appService 'appService.bicep' = if (!deployAsFunc) {
|
2022-05-19 12:29:59 +03:00
|
|
|
scope: resourceGroup
|
|
|
|
name: 'appServiceModule'
|
|
|
|
params: {
|
|
|
|
location: location
|
2022-08-10 11:18:49 +03:00
|
|
|
azureCloud: azureCloud
|
2022-05-19 12:29:59 +03:00
|
|
|
appServicePlanName: appServicePlanName
|
|
|
|
appServiceName: appServiceName
|
|
|
|
keyVaultUri: keyVault.outputs.keyVaultUri
|
|
|
|
cosmosDbUri: cosmos.outputs.cosmosDocumentEndpoint
|
|
|
|
managedIdentityId: managedIdentity.outputs.id
|
|
|
|
storageAccountName: storageAccount.outputs.name
|
2022-08-10 02:09:45 +03:00
|
|
|
workspaceId: logAnalyticsWorkspace.outputs.workspaceId
|
2022-05-19 12:29:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-09 00:36:57 +03:00
|
|
|
// Function App
|
|
|
|
module functionApp 'functionApp.bicep' = if (deployAsFunc) {
|
|
|
|
scope: resourceGroup
|
|
|
|
name: 'functionAppModule'
|
|
|
|
params: {
|
|
|
|
location: location
|
2022-08-10 11:18:49 +03:00
|
|
|
azureCloud: azureCloud
|
2022-08-09 00:36:57 +03:00
|
|
|
functionAppPlanName: appServicePlanName
|
|
|
|
functionAppName: appServiceName
|
|
|
|
keyVaultUri: keyVault.outputs.keyVaultUri
|
|
|
|
cosmosDbUri: cosmos.outputs.cosmosDocumentEndpoint
|
|
|
|
managedIdentityId: managedIdentity.outputs.id
|
|
|
|
storageAccountName: storageAccount.outputs.name
|
2022-08-10 02:09:45 +03:00
|
|
|
workspaceId: logAnalyticsWorkspace.outputs.workspaceId
|
2022-08-09 00:36:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-20 01:05:43 +03:00
|
|
|
// Outputs
|
2022-08-10 02:09:45 +03:00
|
|
|
output appServiceHostName string = deployAsFunc ? functionApp.outputs.functionAppHostName : appService.outputs.appServiceHostName
|