-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate PostgreSQL flexible server setup with Bicep module.
- Loading branch information
1 parent
9d8a76e
commit bbc044f
Showing
3 changed files
with
88 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
metadata description = 'Creates an Azure Database for PostgreSQL - Flexible Server.' | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param sku object | ||
param storage object | ||
param administratorLogin string | ||
@secure() | ||
param administratorLoginPassword string | ||
param databaseNames array = [] | ||
param allowAzureIPsFirewall bool = false | ||
param allowAllIPsFirewall bool = false | ||
param allowedSingleIPs array = [] | ||
|
||
// PostgreSQL version | ||
param version string | ||
|
||
// Latest official version 2022-12-01 does not have Bicep types available | ||
resource postgresServer 'Microsoft.DBforPostgreSQL/flexibleServers@2022-12-01' = { | ||
location: location | ||
tags: tags | ||
name: name | ||
sku: sku | ||
properties: { | ||
version: version | ||
administratorLogin: administratorLogin | ||
administratorLoginPassword: administratorLoginPassword | ||
storage: storage | ||
highAvailability: { | ||
mode: 'Disabled' | ||
} | ||
} | ||
|
||
resource database 'databases' = [for name in databaseNames: { | ||
name: name | ||
}] | ||
|
||
resource firewall_all 'firewallRules' = if (allowAllIPsFirewall) { | ||
name: 'allow-all-IPs' | ||
properties: { | ||
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' | ||
} | ||
} | ||
|
||
resource firewall_single 'firewallRules' = [for ip in allowedSingleIPs: { | ||
name: 'allow-single-${replace(ip, '.', '')}' | ||
properties: { | ||
startIpAddress: ip | ||
endIpAddress: ip | ||
} | ||
}] | ||
|
||
} | ||
|
||
output POSTGRES_DOMAIN_NAME string = postgresServer.properties.fullyQualifiedDomainName |