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

feat(azure): parameterize SKUs #364

Merged
merged 2 commits into from
Jan 22, 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
14 changes: 14 additions & 0 deletions .azure/.test.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,22 @@ param location = 'norwayeast'
param keyVaultSourceKeys = json(readEnvironmentVariable('KEYVAULT_SOURCE_KEYS', '[]'))
param gitSha = readEnvironmentVariable('GIT_SHA', '')

// secrets
param dialogportenPgAdminPassword = readEnvironmentVariable('PG_ADMIN_PASSWORD', '')
param apiManagementDigDirEmail = readEnvironmentVariable('APIM_DIGDIR_EMAIL', '')
param sourceKeyVaultSubscriptionId = readEnvironmentVariable('SOURCE_KEYVAULT_SUBSCRIPTION_ID', '')
param sourceKeyVaultResourceGroup = readEnvironmentVariable('SOURCE_KEYVAULT_RESOURCE_GROUP', '')
param sourceKeyVaultName = readEnvironmentVariable('SOURCE_KEYVAULT_NAME', '')

// SKUs
param APIMSKUName = 'Developer'
param APIMSKUCapcity = 1
param keyVaultSKUName = 'standard'
param keyVaultSKUFamily = 'A'
param appConfigurationSKUName = 'standard'
param appInsightsSKUName = 'PerGB2018'
param slackNotifierStorageAccountSKUName = 'Standard_LRS'
param slackNotifierApplicationServicePlanSKUName = 'Y1'
param slackNotifierApplicationServicePlanSKUTier = 'Dynamic'
param postgresServerSKUName = 'Standard_B1ms'
param postgresServerSKUTier = 'Burstable'
6 changes: 4 additions & 2 deletions .azure/apim/create.bicep
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
param location string
param namePrefix string
param publisherEmail string
param skuName string
param skuCapacity int

resource apim 'Microsoft.ApiManagement/service@2023-03-01-preview' = {
location: location
name: '${namePrefix}-apim'
sku: {
name: 'Developer'
capacity: 1
name: skuName
capacity: skuCapacity
}
properties: {
publisherEmail: publisherEmail
Expand Down
13 changes: 7 additions & 6 deletions .azure/appConfiguration/create.bicep
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
param namePrefix string
param location string
param skuName string

resource appConfig 'Microsoft.AppConfiguration/configurationStores@2023-03-01' = {
name: '${namePrefix}-appConfiguration'
location: location
sku: {
name: 'standard'
name: skuName
}
properties: {
// TODO: Remove
enablePurgeProtection: false
}
resource configStoreKeyValue 'keyValues' = {
name: 'Sentinel'
properties: {
value: '1'
}
}
name: 'Sentinel'
properties: {
value: '1'
}
}
oskogstad marked this conversation as resolved.
Show resolved Hide resolved
}

output endpoint string = appConfig.properties.endpoint
Expand Down
3 changes: 2 additions & 1 deletion .azure/applicationInsights/create.bicep
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
param namePrefix string
param location string
param skuName string

resource appInsightsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
name: '${namePrefix}-insightsWorkspace'
location: location
properties: {
retentionInDays: 30
sku: {
name: 'PerGB2018'
name: skuName
}
workspaceCapping: {
dailyQuotaGb: -1
Expand Down
9 changes: 6 additions & 3 deletions .azure/functionApp/slackNotifier.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ param location string
param applicationInsightsName string
param namePrefix string
param keyVaultName string
param storageAccountSKUName string
param applicationServicePlanSKUName string
param applicationServicePlanSKUTier string

// Storage account names only supports lower case and numbers
var storageAccountName = '${replace(namePrefix, '-', '')}slacknotifiersa'
Expand All @@ -10,7 +13,7 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
name: storageAccountSKUName
}
kind: 'Storage'
properties: {
Expand All @@ -23,8 +26,8 @@ resource applicationServicePlan 'Microsoft.Web/serverfarms@2021-03-01' = {
name: '${namePrefix}-slacknotifier-asp'
location: location
sku: {
name: 'Y1'
tier: 'Dynamic'
name: applicationServicePlanSKUName
tier: applicationServicePlanSKUTier
}
properties: {}
}
Expand Down
6 changes: 4 additions & 2 deletions .azure/keyvault/create.bicep
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
param namePrefix string
param location string
param skuName string
param skuFamily string

var keyVaultName = take('${namePrefix}-kv-${uniqueString(resourceGroup().id)}', 24)

Expand All @@ -11,8 +13,8 @@ resource keyVault 'Microsoft.KeyVault/vaults@2023-07-01' = {
enablePurgeProtection: null // Null is the same as false and false is invalid for some reason
enabledForTemplateDeployment: false
sku: {
family: 'A'
name: 'standard'
name: skuName
family: skuFamily
}
tenantId: subscription().tenantId
accessPolicies: []
Expand Down
88 changes: 88 additions & 0 deletions .azure/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,83 @@ param sourceKeyVaultResourceGroup string
@secure()
param sourceKeyVaultName string

@allowed(
[
'Basic'
'Consumption'
'Developer'
'Isolated'
'Premium'
'Standard'
]
)
param APIMSKUName string

@minValue(1)
param APIMSKUCapcity int

@allowed(
[
'premium'
'standard'
]
)
param keyVaultSKUName string

@allowed([
'A'
])
param keyVaultSKUFamily string

@allowed([
'standard'
])
param appConfigurationSKUName string

@allowed([
'CapacityReservation'
'Free'
'LACluster'
'PerGB2018'
'PerNode'
'Premium'
'Standalone'
'Standard'
])
param appInsightsSKUName string

@allowed([
'Standard_LRS'
'Standard_GRS'
'Standard_RAGRS'
'Standard_ZRS'
'Premium_LRS'
'Premium_ZRS'
])
param slackNotifierStorageAccountSKUName string

@allowed([
'Y1'
])
param slackNotifierApplicationServicePlanSKUName string

@allowed([
'Dynamic'

])
param slackNotifierApplicationServicePlanSKUTier string

@allowed([
'Standard_B1ms'
])
param postgresServerSKUName string
@allowed([
'Burstable'
'GeneralPurpose'
'MemoryOptimized'
])
param postgresServerSKUTier string

var secrets = {
dialogportenPgAdminPassword: dialogportenPgAdminPassword
apiManagementDigDirEmail: apiManagementDigDirEmail
Expand All @@ -40,6 +117,8 @@ module apiManagement 'apim/create.bicep' = {
publisherEmail: secrets.apiManagementDigDirEmail
location: location
namePrefix: namePrefix
skuName: APIMSKUName
skuCapacity: APIMSKUCapcity
}
}

Expand All @@ -49,6 +128,8 @@ module keyVaultModule 'keyvault/create.bicep' = {
params: {
namePrefix: namePrefix
location: location
skuName: keyVaultSKUName
skuFamily: keyVaultSKUFamily
}
}

Expand All @@ -58,6 +139,7 @@ module appConfiguration 'appConfiguration/create.bicep' = {
params: {
namePrefix: namePrefix
location: location
skuName: appConfigurationSKUName
}
}

Expand All @@ -67,6 +149,7 @@ module appInsights 'applicationInsights/create.bicep' = {
params: {
namePrefix: namePrefix
location: location
skuName: appInsightsSKUName
}
}

Expand Down Expand Up @@ -99,6 +182,8 @@ module postgresql 'postgreSql/create.bicep' = {
srcKeyVault: srcKeyVault
srcSecretName: 'dialogportenPgAdminPassword${environment}'
administratorLoginPassword: contains(keyVaultSourceKeys, 'dialogportenPgAdminPassword${environment}') ? srcKeyVaultResource.getSecret('dialogportenPgAdminPassword${environment}') : secrets.dialogportenPgAdminPassword
skuName: postgresServerSKUName
skuTier: postgresServerSKUTier
}
}

Expand Down Expand Up @@ -135,6 +220,9 @@ module slackNotifier 'functionApp/slackNotifier.bicep' = {
keyVaultName: keyVaultModule.outputs.name
namePrefix: namePrefix
applicationInsightsName: appInsights.outputs.appInsightsName
storageAccountSKUName: slackNotifierStorageAccountSKUName
applicationServicePlanSKUName: slackNotifierApplicationServicePlanSKUName
applicationServicePlanSKUTier: slackNotifierApplicationServicePlanSKUTier
}
}

Expand Down
6 changes: 4 additions & 2 deletions .azure/postgreSql/create.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ param namePrefix string
param location string
param keyVaultName string
param srcSecretName string
param skuName string
param skuTier string

@secure()
param srcKeyVault object
Expand Down Expand Up @@ -49,8 +51,8 @@ resource postgres 'Microsoft.DBforPostgreSQL/flexibleServers@2022-12-01' = {
replicationRole: 'Primary'
}
sku: {
name: 'Standard_B1ms'
tier: 'Burstable'
name: skuName
tier: skuTier
}
resource database 'databases' = {
name: databaseName
Expand Down