ipam/deploy/main.bicep

99 строки
2.5 KiB
Bicep
Исходник Обычный вид История

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)}'
// Resource group
2022-05-19 12:29:59 +03:00
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: resourceGroupName
location: location
}
// Authentication related resources
2022-05-19 12:29:59 +03:00
module managedIdentity 'managedIdentity.bicep' = {
name: 'managedIdentityModule'
scope: resourceGroup
params: {
managedIdentityName: managedIdentityName
location: location
}
}
// 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
}
}
// 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
}
}
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
}
}
// Outputs
2022-05-19 12:29:59 +03:00
output appServiceHostName string = appService.outputs.appServiceHostName