Skip to content

update mysql bicep version #17

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

Merged
merged 1 commit into from
Feb 10, 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
45 changes: 15 additions & 30 deletions infra/core/database/mysql/flexibleserver.bicep
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
metadata description = 'Creates an Azure Database for MySQL - Flexible Server.'
param name string
param location string = resourceGroup().location
param tags object = {}

param sku object
param storage object
@description('Database administrator login name')
@minLength(1)
param adminName string = 'mySqlAdmin'
param administratorLogin string
@secure()
param adminPassword string
param administratorLoginPassword string
param highAvailabilityMode string = 'Disabled'
param databaseNames array = []
param allowAzureIPsFirewall bool = false
param allowAllIPsFirewall bool = false
param allowedSingleIPs array = []

@description('MySQL version')
@allowed([
'5.7'
'8.0.21'
])
param version string = '8.0.21'

@allowed([
'Disabled'
'ZoneRedundant'
'SameZone'
])
param highAvailabilityMode string = 'Disabled'
// MySQL version
param version string

resource mysqlServer 'Microsoft.DBforMySQL/flexibleServers@2021-05-01' = {
resource mysqlServer 'Microsoft.DBforMySQL/flexibleServers@2023-06-30' = {
location: location
tags: tags
name: name
sku: sku
properties: {
version: version
administratorLogin: adminName
administratorLoginPassword: adminPassword
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
storage: storage
highAvailability: {
mode: highAvailabilityMode
Expand All @@ -45,33 +34,29 @@ resource mysqlServer 'Microsoft.DBforMySQL/flexibleServers@2021-05-01' = {

resource database 'databases' = [for name in databaseNames: {
name: name
properties: {
charset: 'utf8'
collation: 'utf8_general_ci'
}
}]

resource firewall_all 'firewallRules' = if (allowAllIPsFirewall) {
name: 'allow-all-IPs'
properties: {
startIpAddress: '0.0.0.0'
endIpAddress: '255.255.255.255'
startIpAddress: '0.0.0.0'
endIpAddress: '255.255.255.255'
}
}

resource firewall_azure 'firewallRules' = if (allowAzureIPsFirewall) {
name: 'allow-all-azure-internal-IPs'
properties: {
startIpAddress: '0.0.0.0'
endIpAddress: '0.0.0.0'
startIpAddress: '0.0.0.0'
endIpAddress: '0.0.0.0'
}
}

resource firewall_single 'firewallRules' = [for ip in allowedSingleIPs: {
name: 'allow-single-${replace(ip, '.', '')}'
properties: {
startIpAddress: ip
endIpAddress: ip
startIpAddress: ip
endIpAddress: ip
}
}]

Expand Down
4 changes: 2 additions & 2 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ module mysqlServer 'core/database/mysql/flexibleserver.bicep' = {
storageSizeGB: 20
}
version: '8.0.21'
adminName: mysqlAdminUser
adminPassword: mysqlAdminPassword
administratorLogin: mysqlAdminUser
administratorLoginPassword: mysqlAdminPassword
databaseNames: [ mysqlDatabaseName ]
allowAzureIPsFirewall: true
}
Expand Down