Skip to content

Commit

Permalink
feat: Update avm/res/db-for-postgre-sql/flexible-server - Cross-ref…
Browse files Browse the repository at this point in the history
…erence latest pe and common types (#4300)

## Description

Cross reference latest version of pe module
Update pe output
Update pe multiscope
Cross reference latest version of common types

## Pipeline Reference

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

| Pipeline |
| -------- |
|
[![avm.res.db-for-postgre-sql.flexible-server](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.db-for-postgre-sql.flexible-server.yml/badge.svg?branch=users%2Ferikag%2Fpostgre_update_pe&event=workflow_dispatch)](https://github.com/Azure/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)
- [ ] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] 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.
- [x] 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`.
  - [ ] Update to documentation

## Checklist

- [ ] I'm sure there are no other open Pull Requests for the same
update/change
- [ ] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [ ] 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
eriqua authored Jan 27, 2025
1 parent ccc4bbe commit 3f62007
Show file tree
Hide file tree
Showing 4 changed files with 400 additions and 281 deletions.
11 changes: 6 additions & 5 deletions avm/res/db-for-postgre-sql/flexible-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,7 @@ Configuration details for private endpoints. Used when the desired connectivity
| [`name`](#parameter-privateendpointsname) | string | The name of the Private Endpoint. |
| [`privateDnsZoneGroup`](#parameter-privateendpointsprivatednszonegroup) | object | The private DNS Zone Group to configure for the Private Endpoint. |
| [`privateLinkServiceConnectionName`](#parameter-privateendpointsprivatelinkserviceconnectionname) | string | The name of the private link connection to create. |
| [`resourceGroupName`](#parameter-privateendpointsresourcegroupname) | string | Specify if you want to deploy the Private Endpoint into a different Resource Group than the main resource. |
| [`resourceGroupResourceId`](#parameter-privateendpointsresourcegroupresourceid) | string | The resource ID of the Resource Group the Private Endpoint will be created in. If not specified, the Resource Group of the provided Virtual Network Subnet is used. |
| [`roleAssignments`](#parameter-privateendpointsroleassignments) | array | Array of role assignments to create. |
| [`service`](#parameter-privateendpointsservice) | string | The subresource to deploy the Private Endpoint for. For example "vault" for a Key Vault Private Endpoint. |
| [`tags`](#parameter-privateendpointstags) | object | Tags to be applied on all resources/Resource Groups in this deployment. |
Expand Down Expand Up @@ -2248,9 +2248,9 @@ The name of the private link connection to create.
- MinValue: 7
- MaxValue: 35

### Parameter: `privateEndpoints.resourceGroupName`
### Parameter: `privateEndpoints.resourceGroupResourceId`

Specify if you want to deploy the Private Endpoint into a different Resource Group than the main resource.
The resource ID of the Resource Group the Private Endpoint will be created in. If not specified, the Resource Group of the provided Virtual Network Subnet is used.

- Required: No
- Type: string
Expand Down Expand Up @@ -2694,6 +2694,7 @@ PostgreSQL Server version.
| `fqdn` | string | The FQDN of the PostgreSQL Flexible server. |
| `location` | string | The location the resource was deployed into. |
| `name` | string | The name of the deployed PostgreSQL Flexible server. |
| `privateEndpoints` | array | The private endpoints of the PostgreSQL Flexible server. |
| `resourceGroupName` | string | The resource group of the deployed PostgreSQL Flexible server. |
| `resourceId` | string | The resource ID of the deployed PostgreSQL Flexible server. |

Expand All @@ -2703,8 +2704,8 @@ This section gives you an overview of all local-referenced module files (i.e., o

| Reference | Type |
| :-- | :-- |
| `br/public:avm/res/network/private-endpoint:0.8.0` | Remote reference |
| `br/public:avm/utl/types/avm-common-types:0.4.0` | Remote reference |
| `br/public:avm/res/network/private-endpoint:0.10.1` | Remote reference |
| `br/public:avm/utl/types/avm-common-types:0.5.1` | Remote reference |

## Data Collection

Expand Down
66 changes: 57 additions & 9 deletions avm/res/db-for-postgre-sql/flexible-server/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ param highAvailability string = 'ZoneRedundant'
@description('Optional. The mode to create a new PostgreSQL server.')
param createMode string = 'Default'

import { managedIdentityOnlyUserAssignedType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
import { managedIdentityOnlyUserAssignedType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
@description('Conditional. The managed identity definition for this resource. Required if \'cMKKeyName\' is not empty.')
param managedIdentities managedIdentityOnlyUserAssignedType?

Expand All @@ -115,7 +115,7 @@ param managedIdentities managedIdentityOnlyUserAssignedType?
@description('Optional. Specifies the state of the Threat Protection, whether it is enabled or disabled or a state has not been applied yet on the specific server.')
param serverThreatProtection string = 'Enabled'

import { customerManagedKeyType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
import { customerManagedKeyType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
@description('Optional. The customer managed key definition.')
param customerManagedKey customerManagedKeyType?

Expand Down Expand Up @@ -155,14 +155,14 @@ param databases array = []
@description('Optional. The configurations to create in the server.')
param configurations array = []

import { lockType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
import { lockType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
@description('Optional. The lock settings of the service.')
param lock lockType?

@description('Optional. The replication settings for the server. Can only be set on existing flexible servers.')
param replica replicaType?

import { roleAssignmentType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
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 All @@ -172,11 +172,11 @@ param tags object?
@description('Optional. Enable/Disable usage telemetry for module.')
param enableTelemetry bool = true

import { diagnosticSettingFullType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
import { diagnosticSettingFullType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
@description('Optional. The diagnostic settings of the service.')
param diagnosticSettings diagnosticSettingFullType[]?

import { privateEndpointSingleServiceType } from 'br/public:avm/utl/types/avm-common-types:0.4.0'
import { privateEndpointSingleServiceType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
@description('Optional. Configuration details for private endpoints. Used when the desired connectivity mode is \'Public Access\' and \'delegatedSubnetResourceId\' is NOT used.')
param privateEndpoints privateEndpointSingleServiceType[]?

Expand Down Expand Up @@ -444,10 +444,18 @@ resource flexibleServer_diagnosticSettings 'Microsoft.Insights/diagnosticSetting
}
]

module server_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.8.0' = [
module server_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.10.1' = [
for (privateEndpoint, index) in (privateEndpoints ?? []): if (empty(delegatedSubnetResourceId)) {
name: '${uniqueString(deployment().name, location)}-PostgreSQL-PrivateEndpoint-${index}'
scope: resourceGroup(privateEndpoint.?resourceGroupName ?? '')
scope: !empty(privateEndpoint.?resourceGroupResourceId)
? resourceGroup(
split((privateEndpoint.?resourceGroupResourceId ?? '//'), '/')[2],
split((privateEndpoint.?resourceGroupResourceId ?? '////'), '/')[4]
)
: resourceGroup(
split((privateEndpoint.?subnetResourceId ?? '//'), '/')[2],
split((privateEndpoint.?subnetResourceId ?? '////'), '/')[4]
)
params: {
name: privateEndpoint.?name ?? 'pep-${last(split(flexibleServer.id, '/'))}-${privateEndpoint.?service ?? 'postgresqlServer'}-${index}'
privateLinkServiceConnections: privateEndpoint.?isManualConnection != true
Expand Down Expand Up @@ -511,6 +519,46 @@ output location string = flexibleServer.location
@description('The FQDN of the PostgreSQL Flexible server.')
output fqdn string = flexibleServer.properties.fullyQualifiedDomainName

@description('The private endpoints of the PostgreSQL Flexible server.')
output privateEndpoints array = [
for (pe, i) in (!empty(privateEndpoints) ? array(privateEndpoints) : []): {
name: server_privateEndpoints[i].outputs.name
resourceId: server_privateEndpoints[i].outputs.resourceId
groupId: server_privateEndpoints[i].outputs.?groupId!
customDnsConfigs: server_privateEndpoints[i].outputs.customDnsConfigs
networkInterfaceResourceIds: server_privateEndpoints[i].outputs.networkInterfaceResourceIds
}
]

// =============== //
// Definitions //
// =============== //

@export()
type privateEndpointOutputType = {
@description('The name of the private endpoint.')
name: string

@description('The resource ID of the private endpoint.')
resourceId: string

@description('The group Id for the private endpoint Group.')
groupId: string?

@description('The custom DNS configurations of the private endpoint.')
customDnsConfigs: {
@description('FQDN that resolves to private endpoint IP address.')
fqdn: string?

@description('A list of private IP addresses of the private endpoint.')
ipAddresses: string[]
}[]

@description('The IDs of the network interfaces associated with the private endpoint.')
networkInterfaceResourceIds: string[]
}

@export()
type replicaType = {
@description('''Conditional. Sets the promote mode for a replica server. This is a write only property. 'standalone'
'switchover'. Required if enabling replication.''')
Expand All @@ -522,4 +570,4 @@ type replicaType = {

@description('''Conditional. Used to indicate role of the server in replication set. 'AsyncReplica', 'GeoAsyncReplica', 'None', 'Primary'. Required if enabling replication.''')
role: ('AsyncReplica' | 'GeoAsyncReplica' | 'None' | 'Primary')
}?
}
Loading

0 comments on commit 3f62007

Please sign in to comment.