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
|
|
|
|
|
|
|
|
@description('Service Principal ClientId')
|
|
|
|
param spnClientId string
|
|
|
|
|
|
|
|
@secure()
|
|
|
|
@description('Service Principal Secret')
|
|
|
|
param spnSecret string
|
|
|
|
|
|
|
|
// Naming variables
|
|
|
|
var resourceGroupName = 'ipam-rg-${uniqueString(guid)}'
|
|
|
|
var managedIdentityName = 'ipam-mi-${uniqueString(guid)}'
|
|
|
|
var keyVaultName = 'ipam-kv-${uniqueString(guid)}'
|
|
|
|
var storageName = 'ipamstg${uniqueString(guid)}'
|
|
|
|
|
|
|
|
// App Service Variables
|
|
|
|
var appServicePlanName = 'ipam-asp-${uniqueString(guid)}'
|
|
|
|
var appServiceName = 'ipam-${uniqueString(guid)}'
|
|
|
|
|
|
|
|
// Cosmos Variables
|
|
|
|
var cosmosAccountName = 'ipam-dbacct-${uniqueString(guid)}'
|
|
|
|
|
2022-05-20 01:05:43 +03:00
|
|
|
// Resource group
|
2022-05-19 12:29:59 +03:00
|
|
|
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
|
|
|
|
name: resourceGroupName
|
|
|
|
location: location
|
|
|
|
}
|
|
|
|
|
2022-05-20 01:05:43 +03:00
|
|
|
// Authentication related resources
|
2022-05-19 12:29:59 +03:00
|
|
|
module managedIdentity 'managedIdentity.bicep' = {
|
|
|
|
name: 'managedIdentityModule'
|
|
|
|
scope: resourceGroup
|
|
|
|
params: {
|
|
|
|
managedIdentityName: managedIdentityName
|
|
|
|
location: location
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-20 01:05:43 +03:00
|
|
|
// Security related resources
|
2022-05-19 12:29:59 +03:00
|
|
|
module keyVault 'keyVault.bicep' ={
|
|
|
|
name: 'keyVaultModule'
|
|
|
|
scope: resourceGroup
|
|
|
|
params: {
|
|
|
|
keyVaultName: keyVaultName
|
|
|
|
location: location
|
|
|
|
principalId: managedIdentity.outputs.principalId
|
|
|
|
spnClientId: spnClientId
|
|
|
|
spnSecret: spnSecret
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-20 01:05:43 +03:00
|
|
|
// Data related resources
|
2022-05-19 12:29:59 +03:00
|
|
|
module cosmos 'cosmos.bicep' = {
|
|
|
|
name: 'cosmosModule'
|
|
|
|
scope: resourceGroup
|
|
|
|
params: {
|
|
|
|
location: location
|
|
|
|
cosmosAccountName: cosmosAccountName
|
|
|
|
keyVaultName: keyVault.outputs.keyVaultName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compute related resources
|
2022-05-19 12:29:59 +03:00
|
|
|
module appService 'appService.bicep' = {
|
|
|
|
scope: resourceGroup
|
|
|
|
name: 'appServiceModule'
|
|
|
|
params: {
|
|
|
|
location: location
|
|
|
|
appServicePlanName: appServicePlanName
|
|
|
|
appServiceName: appServiceName
|
|
|
|
keyVaultUri: keyVault.outputs.keyVaultUri
|
|
|
|
cosmosDbUri: cosmos.outputs.cosmosDocumentEndpoint
|
|
|
|
managedIdentityClientId: managedIdentity.outputs.clientId
|
|
|
|
managedIdentityId: managedIdentity.outputs.id
|
|
|
|
storageAccountName: storageAccount.outputs.name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-20 01:05:43 +03:00
|
|
|
// Outputs
|
2022-05-19 12:29:59 +03:00
|
|
|
output appServiceHostName string = appService.outputs.appServiceHostName
|