Skip to content
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

fix: avm/res/db for postgre sql/flexible server #3080

Merged
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
70 changes: 58 additions & 12 deletions avm/res/db-for-postgre-sql/flexible-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ module flexibleServer 'br/public:avm/res/db-for-postgre-sql/flexible-server:<ver
params: {
// Required parameters
name: 'dfpsfsmin001'
skuName: 'Standard_B2s'
tier: 'Burstable'
skuName: 'Standard_D2s_v3'
tier: 'GeneralPurpose'
// Non-required parameters
administratorLogin: 'adminUserName'
administratorLoginPassword: '<administratorLoginPassword>'
administrators: [
{
objectId: '<objectId>'
principalName: '<principalName>'
principalType: 'ServicePrincipal'
}
]
geoRedundantBackup: 'Enabled'
highAvailability: 'ZoneRedundant'
location: '<location>'
}
}
Expand All @@ -81,21 +87,27 @@ module flexibleServer 'br/public:avm/res/db-for-postgre-sql/flexible-server:<ver
"value": "dfpsfsmin001"
},
"skuName": {
"value": "Standard_B2s"
"value": "Standard_D2s_v3"
},
"tier": {
"value": "Burstable"
"value": "GeneralPurpose"
},
// Non-required parameters
"administratorLogin": {
"value": "adminUserName"
},
"administratorLoginPassword": {
"value": "<administratorLoginPassword>"
"administrators": {
"value": [
{
"objectId": "<objectId>",
"principalName": "<principalName>",
"principalType": "ServicePrincipal"
}
]
},
"geoRedundantBackup": {
"value": "Enabled"
},
"highAvailability": {
"value": "ZoneRedundant"
},
"location": {
"value": "<location>"
}
Expand Down Expand Up @@ -697,7 +709,14 @@ module flexibleServer 'br/public:avm/res/db-for-postgre-sql/flexible-server:<ver
}
]
geoRedundantBackup: 'Enabled'
highAvailability: 'ZoneRedundant'
location: '<location>'
maintenanceWindow: {
customWindow: 'Enabled'
dayOfWeek: 0
startHour: 1
startMinute: 0
}
privateDnsZoneArmResourceId: '<privateDnsZoneArmResourceId>'
tags: {
Environment: 'Non-Prod'
Expand Down Expand Up @@ -782,9 +801,20 @@ module flexibleServer 'br/public:avm/res/db-for-postgre-sql/flexible-server:<ver
"geoRedundantBackup": {
"value": "Enabled"
},
"highAvailability": {
"value": "ZoneRedundant"
},
"location": {
"value": "<location>"
},
"maintenanceWindow": {
"value": {
"customWindow": "Enabled",
"dayOfWeek": 0,
"startHour": 1,
"startMinute": 0
}
},
"privateDnsZoneArmResourceId": {
"value": "<privateDnsZoneArmResourceId>"
},
Expand Down Expand Up @@ -1314,7 +1344,15 @@ Properties for the maintenence window. If provided, 'customWindow' property must

- Required: No
- Type: object
- Default: `{}`
- Default:
```Bicep
{
customWindow: 'Enabled'
dayOfWeek: 0
startHour: 1
startMinute: 0
}
```

### Parameter: `passwordAuth`

Expand Down Expand Up @@ -1361,6 +1399,7 @@ Array of role assignments to create.
| [`conditionVersion`](#parameter-roleassignmentsconditionversion) | string | Version of the condition. |
| [`delegatedManagedIdentityResourceId`](#parameter-roleassignmentsdelegatedmanagedidentityresourceid) | string | The Resource Id of the delegated managed identity resource. |
| [`description`](#parameter-roleassignmentsdescription) | string | The description of the role assignment. |
| [`name`](#parameter-roleassignmentsname) | string | The name (as GUID) of the role assignment. If not provided, a GUID will be generated. |
| [`principalType`](#parameter-roleassignmentsprincipaltype) | string | The principal type of the assigned principal ID. |

### Parameter: `roleAssignments.principalId`
Expand Down Expand Up @@ -1411,6 +1450,13 @@ The description of the role assignment.
- Required: No
- Type: string

### Parameter: `roleAssignments.name`

The name (as GUID) of the role assignment. If not provided, a GUID will be generated.

- Required: No
- Type: string

### Parameter: `roleAssignments.principalType`

The principal type of the assigned principal ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.170.59819",
"templateHash": "17302939650459446486"
"version": "0.29.47.4906",
"templateHash": "9786947819042824705"
},
"name": "DBforPostgreSQL Flexible Server Administrators",
"description": "This module deploys a DBforPostgreSQL Flexible Server Administrator.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.170.59819",
"templateHash": "4808844582468160626"
"version": "0.29.47.4906",
"templateHash": "3802666632340288344"
},
"name": "DBforPostgreSQL Flexible Server Configurations",
"description": "This module deploys a DBforPostgreSQL Flexible Server Configuration.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.170.59819",
"templateHash": "12256776332622303948"
"version": "0.29.47.4906",
"templateHash": "17501165975344742322"
},
"name": "DBforPostgreSQL Flexible Server Databases",
"description": "This module deploys a DBforPostgreSQL Flexible Server Database.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.170.59819",
"templateHash": "12309357869547394167"
"version": "0.29.47.4906",
"templateHash": "5110779562094536429"
},
"name": "DBforPostgreSQL Flexible Server Firewall Rules",
"description": "This module deploys a DBforPostgreSQL Flexible Server Firewall Rule.",
Expand Down
41 changes: 28 additions & 13 deletions avm/res/db-for-postgre-sql/flexible-server/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ param managedIdentities managedIdentitiesType
param customerManagedKey customerManagedKeyType

@description('Optional. Properties for the maintenence window. If provided, \'customWindow\' property must exist and set to \'Enabled\'.')
param maintenanceWindow object = {}
param maintenanceWindow object = {
customWindow: 'Enabled'
dayOfWeek: 0
startHour: 1
startMinute: 0
}

@description('Conditional. Required if \'createMode\' is set to \'PointInTimeRestore\'.')
param pointInTimeUTC string = ''
Expand Down Expand Up @@ -182,6 +187,17 @@ var builtInRoleNames = {
)
}

var formattedRoleAssignments = [
for (roleAssignment, index) in (roleAssignments ?? []): union(roleAssignment, {
roleDefinitionId: builtInRoleNames[?roleAssignment.roleDefinitionIdOrName] ?? (contains(
roleAssignment.roleDefinitionIdOrName,
'/providers/Microsoft.Authorization/roleDefinitions/'
)
? roleAssignment.roleDefinitionIdOrName
: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleAssignment.roleDefinitionIdOrName))
})
]

#disable-next-line no-deployments-resources
resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableTelemetry) {
name: '46d3xbcp.res.dbforpostgresql-flexibleserver.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name, location), 0, 4)}'
Expand Down Expand Up @@ -292,14 +308,10 @@ resource flexibleServer_lock 'Microsoft.Authorization/locks@2020-05-01' = if (!e
}

resource flexibleServer_roleAssignments 'Microsoft.Authorization/roleAssignments@2022-04-01' = [
for (roleAssignment, index) in (roleAssignments ?? []): {
name: guid(flexibleServer.id, roleAssignment.principalId, roleAssignment.roleDefinitionIdOrName)
for (roleAssignment, index) in (formattedRoleAssignments ?? []): {
name: roleAssignment.?name ?? guid(flexibleServer.id, roleAssignment.principalId, roleAssignment.roleDefinitionId)
properties: {
roleDefinitionId: contains(builtInRoleNames, roleAssignment.roleDefinitionIdOrName)
? builtInRoleNames[roleAssignment.roleDefinitionIdOrName]
: contains(roleAssignment.roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/')
? roleAssignment.roleDefinitionIdOrName
: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleAssignment.roleDefinitionIdOrName)
roleDefinitionId: roleAssignment.roleDefinitionId
principalId: roleAssignment.principalId
description: roleAssignment.?description
principalType: roleAssignment.?principalType
Expand All @@ -317,8 +329,8 @@ module flexibleServer_databases 'database/main.bicep' = [
params: {
name: database.name
flexibleServerName: flexibleServer.name
collation: contains(database, 'collation') ? database.collation : ''
charset: contains(database, 'charset') ? database.charset : ''
collation: database.?collation ?? ''
charset: database.?charset ?? ''
}
}
]
Expand All @@ -345,8 +357,8 @@ module flexibleServer_configurations 'configuration/main.bicep' = [
params: {
name: configuration.name
flexibleServerName: flexibleServer.name
source: contains(configuration, 'source') ? configuration.source : ''
value: contains(configuration, 'value') ? configuration.value : ''
source: configuration.?source ?? ''
value: configuration.?value ?? ''
}
dependsOn: [
flexibleServer_firewallRules
Expand All @@ -362,7 +374,7 @@ module flexibleServer_administrators 'administrator/main.bicep' = [
objectId: administrator.objectId
principalName: administrator.principalName
principalType: administrator.principalType
tenantId: contains(administrator, 'tenantId') ? administrator.tenantId : tenant().tenantId
tenantId: administrator.?tenantId ?? tenant().tenantId
}
}
]
Expand Down Expand Up @@ -429,6 +441,9 @@ type lockType = {
}?

type roleAssignmentType = {
@description('Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated.')
name: string?

@description('Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.')
roleDefinitionIdOrName: string

Expand Down
Loading