-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpostgresql.bicep
95 lines (84 loc) · 2.67 KB
/
postgresql.bicep
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
param location string = resourceGroup().location
param subnetId string
param vnetID string
param psqlResourceName string
param psqlSkuCapacity int
param psqlLogin string
@secure()
param psqlPassword string
param psqlDatabaseName string
resource postgreSQL 'Microsoft.DBForPostgreSQL/servers@2017-12-01' = {
name: psqlResourceName
location: location
properties: {
administratorLogin: psqlLogin
administratorLoginPassword: psqlPassword
createMode: 'Default'
sslEnforcement: 'Enabled'
publicNetworkAccess: 'Enabled'
version: '10'
}
sku: {
name: 'GP_Gen5_2'
tier: 'GeneralPurpose' // TODO: Basic tier is probably fine (and cheaper!) for small network deployments.
family: 'Gen5'
capacity: psqlSkuCapacity
}
}
resource postgreSQLVNetRule 'Microsoft.DBForPostgreSQL/servers/virtualNetworkRules@2017-12-01' = {
name: '${postgreSQL.name}/vnet'
properties: {
virtualNetworkSubnetId: subnetId
ignoreMissingVnetServiceEndpoint: true
}
}
resource postgreSQLDatabase 'Microsoft.DBForPostgreSQL/servers/databases@2017-12-01-preview' = {
name: '${postgreSQL.name}/${psqlDatabaseName}'
}
resource postgreSQLPrivateEndpoint 'Microsoft.Network/privateEndpoints@2020-06-01' = {
name: '${psqlResourceName}-privateendpoint'
location: location
properties: {
privateLinkServiceConnections: [
{
name: '${psqlResourceName}-privateendpoint'
properties: {
privateLinkServiceId: postgreSQL.id
groupIds: [
'postgresqlServer'
]
}
}
]
subnet: {
id: subnetId
}
}
}
var privateDnsZoneName = 'privatelink.postgres.database.azure.com'
resource privateDnsZone 'Microsoft.Network/privateDnsZones@2018-09-01' = {
name: privateDnsZoneName
location: 'global'
}
resource privateDnsZoneVNetLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2018-09-01' = {
name: '${privateDnsZone.name}/${uniqueString(vnetID)}'
location: 'global'
properties: {
registrationEnabled: false
virtualNetwork: {
id: vnetID
}
}
}
resource privateDnsZoneARecord 'Microsoft.Network/privateDnsZones/A@2018-09-01' = {
name: '${privateDnsZone.name}/${psqlResourceName}'
properties: {
aRecords: [
{
ipv4Address: postgreSQLPrivateEndpoint.properties.customDnsConfigs[0].ipAddresses[0]
}
]
ttl: 3600
}
}
output fqdn string = postgreSQL.properties.fullyQualifiedDomainName