Skip to content

Commit

Permalink
fix: Added depends on to advanced threat protection (#4363)
Browse files Browse the repository at this point in the history
## Description

Added depends on to advanced threat protection.
Added parameter to toggle on or off advanced threat protection.

Closes #4289

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.db-for-postgre-sql.flexible-server](https://github.com/arnoldna/bicep-registry-modules/actions/workflows/avm.res.db-for-postgre-sql.flexible-server.yml/badge.svg?branch=avm%2Fres%2Fdb-for-postgre-sql%2Fflexible-serve)](https://github.com/arnoldna/bicep-registry-modules/actions/workflows/avm.res.db-for-postgre-sql.flexible-server.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [ X] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [X ] Someone has opened a bug report issue, and I have included
"Closes #{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ X] Update to documentation

## Checklist

- [X ] I'm sure there are no other open Pull Requests for the same
update/change
- [ X] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [X ] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->
  • Loading branch information
arnoldna authored Feb 2, 2025
1 parent feee477 commit 55993f1
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 17 deletions.
11 changes: 11 additions & 0 deletions avm/res/db-for-postgre-sql/flexible-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,7 @@ param tags = {
| [`databases`](#parameter-databases) | array | The databases to create in the server. |
| [`delegatedSubnetResourceId`](#parameter-delegatedsubnetresourceid) | string | Delegated subnet arm resource ID. Used when the desired connectivity mode is 'Private Access' - virtual network integration. |
| [`diagnosticSettings`](#parameter-diagnosticsettings) | array | The diagnostic settings of the service. |
| [`enableAdvancedThreatProtection`](#parameter-enableadvancedthreatprotection) | bool | Enable/Disable advanced threat protection. |
| [`enableTelemetry`](#parameter-enabletelemetry) | bool | Enable/Disable usage telemetry for module. |
| [`firewallRules`](#parameter-firewallrules) | array | The firewall rules to create in the PostgreSQL flexible server. |
| [`geoRedundantBackup`](#parameter-georedundantbackup) | string | A value indicating whether Geo-Redundant backup is enabled on the server. Should be disabled if 'cMKKeyName' is not empty. |
Expand Down Expand Up @@ -1777,6 +1778,16 @@ Resource ID of the diagnostic log analytics workspace. For security reasons, it
- MinValue: 7
- MaxValue: 35

### Parameter: `enableAdvancedThreatProtection`

Enable/Disable advanced threat protection.

- Required: No
- Type: bool
- Default: `True`
- MinValue: 7
- MaxValue: 35

### Parameter: `enableTelemetry`

Enable/Disable usage telemetry for module.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "16643531997327278217"
"version": "0.33.13.18514",
"templateHash": "9438694500506305843"
},
"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.32.4.45862",
"templateHash": "6141187485193116497"
"version": "0.33.13.18514",
"templateHash": "17600786812294347393"
},
"name": "DBforPostgreSQL Flexible Server Advanced Threat Protection",
"description": "This module deploys a DBforPostgreSQL Advanced Threat Protection."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "17791142604055425268"
"version": "0.33.13.18514",
"templateHash": "14381841795302215842"
},
"name": "DBforPostgreSQL Flexible Server Configurations",
"description": "This module deploys a DBforPostgreSQL Flexible Server Configuration."
Expand Down
4 changes: 2 additions & 2 deletions avm/res/db-for-postgre-sql/flexible-server/database/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "15358721384580155368"
"version": "0.33.13.18514",
"templateHash": "12559382321541199726"
},
"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.32.4.45862",
"templateHash": "1547810610444554016"
"version": "0.33.13.18514",
"templateHash": "533163168353951900"
},
"name": "DBforPostgreSQL Flexible Server Firewall Rules",
"description": "This module deploys a DBforPostgreSQL Flexible Server Firewall Rule."
Expand Down
10 changes: 8 additions & 2 deletions avm/res/db-for-postgre-sql/flexible-server/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ param lock lockType?
@description('Optional. The replication settings for the server. Can only be set on existing flexible servers.')
param replica replicaType?

@description('Optional. Enable/Disable advanced threat protection.')
param enableAdvancedThreatProtection bool = true

import { roleAssignmentType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
@description('Optional. Array of role assignments to create.')
param roleAssignments roleAssignmentType[]?
Expand Down Expand Up @@ -283,7 +286,7 @@ resource flexibleServer 'Microsoft.DBforPostgreSQL/flexibleServers@2024-08-01' =
dataEncryption: !empty(customerManagedKey)
? {
primaryKeyURI: !empty(customerManagedKey.?keyVersion ?? '')
? '${cMKKeyVault::cMKKey.properties.keyUri}/${customerManagedKey!.keyVersion}'
? '${cMKKeyVault::cMKKey.properties.keyUri}/${customerManagedKey!.?keyVersion}'
: cMKKeyVault::cMKKey.properties.keyUriWithVersion
primaryUserAssignedIdentityId: cMKUserAssignedIdentity.id
type: 'AzureKeyVault'
Expand Down Expand Up @@ -407,12 +410,15 @@ module flexibleServer_administrators 'administrator/main.bicep' = [
}
]

module flexibleServer_advancedThreatProtection 'advanced-threat-protection/main.bicep' = {
module flexibleServer_advancedThreatProtection 'advanced-threat-protection/main.bicep' = if (enableAdvancedThreatProtection) {
name: '${uniqueString(deployment().name, location)}-PostgreSQL-Threat'
params: {
serverThreatProtection: serverThreatProtection
flexibleServerName: flexibleServer.name
}
dependsOn: [
flexibleServer_administrators
]
}

resource flexibleServer_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = [
Expand Down
15 changes: 12 additions & 3 deletions avm/res/db-for-postgre-sql/flexible-server/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "12436555269178944742"
"templateHash": "8102121291373013517"
},
"name": "DBforPostgreSQL Flexible Servers",
"description": "This module deploys a DBforPostgreSQL Flexible Server."
Expand Down Expand Up @@ -927,6 +927,13 @@
"description": "Optional. The replication settings for the server. Can only be set on existing flexible servers."
}
},
"enableAdvancedThreatProtection": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Optional. Enable/Disable advanced threat protection."
}
},
"roleAssignments": {
"type": "array",
"items": {
Expand Down Expand Up @@ -1063,7 +1070,7 @@
"geoRedundantBackup": "[parameters('geoRedundantBackup')]"
},
"createMode": "[parameters('createMode')]",
"dataEncryption": "[if(not(empty(parameters('customerManagedKey'))), createObject('primaryKeyURI', if(not(empty(coalesce(tryGet(parameters('customerManagedKey'), 'keyVersion'), ''))), format('{0}/{1}', reference('cMKKeyVault::cMKKey').keyUri, parameters('customerManagedKey').keyVersion), reference('cMKKeyVault::cMKKey').keyUriWithVersion), 'primaryUserAssignedIdentityId', extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '//'), '/')[2], split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '////'), '/')[4]), 'Microsoft.ManagedIdentity/userAssignedIdentities', last(split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), 'dummyMsi'), '/'))), 'type', 'AzureKeyVault'), null())]",
"dataEncryption": "[if(not(empty(parameters('customerManagedKey'))), createObject('primaryKeyURI', if(not(empty(coalesce(tryGet(parameters('customerManagedKey'), 'keyVersion'), ''))), format('{0}/{1}', reference('cMKKeyVault::cMKKey').keyUri, tryGet(parameters('customerManagedKey'), 'keyVersion')), reference('cMKKeyVault::cMKKey').keyUriWithVersion), 'primaryUserAssignedIdentityId', extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '//'), '/')[2], split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '////'), '/')[4]), 'Microsoft.ManagedIdentity/userAssignedIdentities', last(split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), 'dummyMsi'), '/'))), 'type', 'AzureKeyVault'), null())]",
"highAvailability": {
"mode": "[parameters('highAvailability')]",
"standbyAvailabilityZone": "[if(equals(parameters('highAvailability'), 'SameZone'), parameters('availabilityZone'), null())]"
Expand Down Expand Up @@ -1621,6 +1628,7 @@
]
},
"flexibleServer_advancedThreatProtection": {
"condition": "[parameters('enableAdvancedThreatProtection')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2022-09-01",
"name": "[format('{0}-PostgreSQL-Threat', uniqueString(deployment().name, parameters('location')))]",
Expand Down Expand Up @@ -1710,7 +1718,8 @@
}
},
"dependsOn": [
"flexibleServer"
"flexibleServer",
"flexibleServer_administrators"
]
},
"server_privateEndpoints": {
Expand Down
4 changes: 2 additions & 2 deletions avm/res/db-for-postgre-sql/flexible-server/version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#",
"version": "0.8",
"version": "0.9",
"pathFilters": [
"./main.json"
]
}
}

0 comments on commit 55993f1

Please sign in to comment.