diff --git a/.github/workflows/cms.yaml b/.github/workflows/cms.yaml index fb2bfb9..a394194 100644 --- a/.github/workflows/cms.yaml +++ b/.github/workflows/cms.yaml @@ -108,4 +108,5 @@ jobs: identityName=${{ needs.deploy_infra.outputs.identityName }} cmsImageName=${{ needs.deploy_infra.outputs.containerRegistryLoginServer }}/cms:latest cmsInitImageName=${{ needs.deploy_infra.outputs.containerRegistryLoginServer }}/cms/init:latest + databaseName=${{ vars.CMS_DATABASE_NAME }} region: ${{ vars.AZURE_REGION }} diff --git a/infrastructure/cms/main.bicep b/infrastructure/cms/main.bicep index f0ea96a..cbf2761 100644 --- a/infrastructure/cms/main.bicep +++ b/infrastructure/cms/main.bicep @@ -1,6 +1,7 @@ import { appendHash } from '../utilities.bicep' param databaseClient string +param databaseName string param logAnalyticsWorkspaceName string param keyVaultName string param registryName string @@ -27,6 +28,7 @@ resource cmsIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-3 module mySql '../modules/sql.bicep' = { name: 'deployMysql' params: { + databaseName: databaseName sqlPassword: keyVault.getSecret(mySqlAdminPasswordKeyVaultReference) } } diff --git a/infrastructure/modules/sql.bicep b/infrastructure/modules/sql.bicep index 5cfa3ab..a6a4530 100644 --- a/infrastructure/modules/sql.bicep +++ b/infrastructure/modules/sql.bicep @@ -5,6 +5,7 @@ param skuTier string = 'Burstable' param flexibleMySqlServerLocation string = 'swedencentral' @secure() param sqlPassword string +param databaseName string resource mySql 'Microsoft.DBforMySQL/flexibleServers@2023-12-30' = { name: appendHash('mysql-cms') @@ -20,6 +21,11 @@ resource mySql 'Microsoft.DBforMySQL/flexibleServers@2023-12-30' = { } } +resource mySqlDatabase 'Microsoft.DBforMySQL/flexibleServers/databases@2023-12-30' = { + parent: mySql + name: databaseName +} + resource allowAzureServicesToMySql 'Microsoft.DBforMySQL/flexibleServers/firewallRules@2023-12-30' = { parent: mySql name: 'AllowAllAzureServicesAndResourcesWithinAzureIps'