Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
creating database through Bicep
Browse files Browse the repository at this point in the history
  • Loading branch information
Physer committed Dec 17, 2024
1 parent 011a402 commit 37bbd3d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 2 additions & 0 deletions infrastructure/cms/main.bicep
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { appendHash } from '../utilities.bicep'

param databaseClient string
param databaseName string
param logAnalyticsWorkspaceName string
param keyVaultName string
param registryName string
Expand All @@ -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)
}
}
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/modules/sql.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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'
Expand Down

0 comments on commit 37bbd3d

Please sign in to comment.