-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.bicep
More file actions
111 lines (94 loc) · 2.91 KB
/
main.bicep
File metadata and controls
111 lines (94 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// PostgreSQL Flexible Server sample — Bicep template
//
// Deploys a PostgreSQL Flexible Server with a database and firewall rule.
//
// NOTE: Bicep deployments use the LocalStack ARM template parser, which is an
// x86-64 binary. On ARM64 machines (e.g. Apple Silicon), this requires Rosetta
// or an x86-64 Docker environment.
// Parameters
@description('Specifies the name prefix for PostgreSQL Flexible Server resources.')
@minLength(3)
@maxLength(10)
param serverNamePrefix string = 'pgflex'
@description('Specifies the location for all resources.')
param location string = resourceGroup().location
@description('Specifies the administrator login name.')
param administratorLogin string = 'pgadmin'
@description('Specifies the administrator login password.')
@secure()
param administratorLoginPassword string
@description('Specifies the PostgreSQL version.')
@allowed([
'13'
'14'
'15'
'16'
])
param version string = '16'
@description('Specifies the SKU name for the server.')
param skuName string = 'B_Standard_B1ms'
@description('Specifies the SKU tier for the server.')
@allowed([
'Burstable'
'GeneralPurpose'
'MemoryOptimized'
])
param skuTier string = 'Burstable'
@description('Specifies the storage size in GB.')
param storageSizeGB int = 32
@description('Specifies the name of the database to create.')
param databaseName string = 'sampledb'
@description('Specifies the firewall rule name.')
param firewallRuleName string = 'allow-all'
@description('Specifies the start IP address for the firewall rule.')
param firewallStartIp string = '0.0.0.0'
@description('Specifies the end IP address for the firewall rule.')
param firewallEndIp string = '255.255.255.255'
// Variables
var serverName = '${serverNamePrefix}-${uniqueString(resourceGroup().id)}'
// Resources
resource server 'Microsoft.DBforPostgreSQL/flexibleServers@2024-08-01' = {
name: serverName
location: location
sku: {
name: skuName
tier: skuTier
}
properties: {
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
version: version
storage: {
storageSizeGB: storageSizeGB
}
highAvailability: {
mode: 'Disabled'
}
backup: {
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
}
}
}
resource database 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2024-08-01' = {
name: databaseName
parent: server
properties: {
charset: 'UTF8'
collation: 'en_US.utf8'
}
}
resource firewallRule 'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2024-08-01' = {
name: firewallRuleName
parent: server
properties: {
startIpAddress: firewallStartIp
endIpAddress: firewallEndIp
}
}
// Outputs
output serverName string = server.name
output serverFqdn string = server.properties.fullyQualifiedDomainName
output databaseName string = database.name
output firewallRuleName string = firewallRule.name
output serverId string = server.id