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 1 commit
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
10 changes: 10 additions & 0 deletions .azure/.test.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ 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 APIM_SKU = 'Developer'
param keyVaultSKU = 'standard'
param appConfigurationSKU = 'standard'
param appInsightsSKU = 'PerGB2018'
param slackNotifierStorageAccountSKU = 'Standard_LRS'
param slackNotifierSKU = 'Y1'
param postgresServerSKU = 'Standard_B1ms'
3 changes: 2 additions & 1 deletion .azure/apim/create.bicep
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
param location string
param namePrefix string
param publisherEmail string
param sku string

resource apim 'Microsoft.ApiManagement/service@2023-03-01-preview' = {
location: location
name: '${namePrefix}-apim'
sku: {
name: 'Developer'
name: sku
capacity: 1
arealmaas marked this conversation as resolved.
Show resolved Hide resolved
}
properties: {
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 sku string

resource appConfig 'Microsoft.AppConfiguration/configurationStores@2023-03-01' = {
name: '${namePrefix}-appConfiguration'
location: location
sku: {
name: 'standard'
name: sku
}
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 sku string

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

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

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

Expand All @@ -12,7 +13,7 @@ resource keyVault 'Microsoft.KeyVault/vaults@2023-07-01' = {
enabledForTemplateDeployment: false
sku: {
family: 'A'
name: 'standard'
name: sku
}
tenantId: subscription().tenantId
accessPolicies: []
Expand Down
60 changes: 60 additions & 0 deletions .azure/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,59 @@ param sourceKeyVaultResourceGroup string
@secure()
param sourceKeyVaultName string

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

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

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

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

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

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

@allowed([
'Standard_B1ms'
])
param postgresServerSKU string

var secrets = {
dialogportenPgAdminPassword: dialogportenPgAdminPassword
apiManagementDigDirEmail: apiManagementDigDirEmail
Expand All @@ -40,6 +93,7 @@ module apiManagement 'apim/create.bicep' = {
publisherEmail: secrets.apiManagementDigDirEmail
location: location
namePrefix: namePrefix
sku: APIM_SKU
}
}

Expand All @@ -49,6 +103,7 @@ module keyVaultModule 'keyvault/create.bicep' = {
params: {
namePrefix: namePrefix
location: location
sku: keyVaultSKU
}
}

Expand All @@ -58,6 +113,7 @@ module appConfiguration 'appConfiguration/create.bicep' = {
params: {
namePrefix: namePrefix
location: location
sku: appConfigurationSKU
}
}

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

Expand Down Expand Up @@ -99,6 +156,7 @@ module postgresql 'postgreSql/create.bicep' = {
srcKeyVault: srcKeyVault
srcSecretName: 'dialogportenPgAdminPassword${environment}'
administratorLoginPassword: contains(keyVaultSourceKeys, 'dialogportenPgAdminPassword${environment}') ? srcKeyVaultResource.getSecret('dialogportenPgAdminPassword${environment}') : secrets.dialogportenPgAdminPassword
sku: postgresServerSKU
}
}

Expand Down Expand Up @@ -135,6 +193,8 @@ module slackNotifier 'functionApp/slackNotifier.bicep' = {
keyVaultName: keyVaultModule.outputs.name
namePrefix: namePrefix
applicationInsightsName: appInsights.outputs.appInsightsName
storageAccountSKU: slackNotifierStorageAccountSKU
applicationServicePlanSKU: slackNotifierSKU
}
}

Expand Down
3 changes: 2 additions & 1 deletion .azure/postgreSql/create.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ param namePrefix string
param location string
param keyVaultName string
param srcSecretName string
param sku string

@secure()
param srcKeyVault object
Expand Down Expand Up @@ -49,7 +50,7 @@ resource postgres 'Microsoft.DBforPostgreSQL/flexibleServers@2022-12-01' = {
replicationRole: 'Primary'
}
sku: {
name: 'Standard_B1ms'
name: sku
tier: 'Burstable'
arealmaas marked this conversation as resolved.
Show resolved Hide resolved
}
resource database 'databases' = {
Expand Down