Skip to content

Commit

Permalink
feat: avm/res/search/search-service improvements (Azure#3074)
Browse files Browse the repository at this point in the history
## Description

PR contains a few improvements of the `avm/res/search/search-service`
module:
- the casing of allowed values of the parameter `publicNetworkAccess`
aligned with the remaining modules
  - old allowed values: `enabled`/`disabled`
  - new values before: `Enabled`/`Disabled`
  - Resolves Azure#2984 
- new output `privateEndpoints` with properties of the deployed private
endpoints
  - Resolves Azure#3022 
- update of the Private Endpoint implementation to the newest schema
- fix of a [use the safe access
operator](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/linter-rule-use-safe-access)
linter warning
- fix of the telemetry identifier causing the static validation to fail
  - fixes Azure#3077 
- added uniqueness for the name of the key vault used as dependency in
the `pe` test case

## Pipeline Reference

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

| Pipeline |
| -------- |
|
[![avm.res.search.search-service](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.search.search-service.yml/badge.svg?branch=users%2Fkrbar%2FsearchUpdates)](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.search.search-service.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`.
- [x] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] 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
krbar authored Aug 21, 2024
1 parent 9cef9b3 commit 6df8e94
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 105 deletions.
115 changes: 88 additions & 27 deletions avm/res/search/search-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,23 +322,31 @@ module searchService 'br/public:avm/res/search/search-service:<version>' = {
applicationSecurityGroupResourceIds: [
'<applicationSecurityGroupResourceId>'
]
privateDnsZoneResourceIds: [
'<privateDNSZoneResourceId>'
]
privateDnsZoneGroup: {
privateDnsZoneGroupConfigs: [
{
privateDnsZoneResourceId: '<privateDnsZoneResourceId>'
}
]
}
subnetResourceId: '<subnetResourceId>'
tags: {
Environment: 'Non-Prod'
Role: 'DeploymentValidation'
}
}
{
privateDnsZoneResourceIds: [
'<privateDNSZoneResourceId>'
]
privateDnsZoneGroup: {
privateDnsZoneGroupConfigs: [
{
privateDnsZoneResourceId: '<privateDnsZoneResourceId>'
}
]
}
subnetResourceId: '<subnetResourceId>'
}
]
publicNetworkAccess: 'disabled'
publicNetworkAccess: 'Disabled'
sharedPrivateLinkResources: [
{
groupId: 'blob'
Expand Down Expand Up @@ -387,25 +395,33 @@ module searchService 'br/public:avm/res/search/search-service:<version>' = {
"applicationSecurityGroupResourceIds": [
"<applicationSecurityGroupResourceId>"
],
"privateDnsZoneResourceIds": [
"<privateDNSZoneResourceId>"
],
"privateDnsZoneGroup": {
"privateDnsZoneGroupConfigs": [
{
"privateDnsZoneResourceId": "<privateDnsZoneResourceId>"
}
]
},
"subnetResourceId": "<subnetResourceId>",
"tags": {
"Environment": "Non-Prod",
"Role": "DeploymentValidation"
}
},
{
"privateDnsZoneResourceIds": [
"<privateDNSZoneResourceId>"
],
"privateDnsZoneGroup": {
"privateDnsZoneGroupConfigs": [
{
"privateDnsZoneResourceId": "<privateDnsZoneResourceId>"
}
]
},
"subnetResourceId": "<subnetResourceId>"
}
]
},
"publicNetworkAccess": {
"value": "disabled"
"value": "Disabled"
},
"sharedPrivateLinkResources": {
"value": [
Expand Down Expand Up @@ -627,7 +643,7 @@ module searchService 'br/public:avm/res/search/search-service:<version>' = {
| [`networkRuleSet`](#parameter-networkruleset) | object | Network specific rules that determine how the Azure Cognitive Search service may be reached. |
| [`partitionCount`](#parameter-partitioncount) | int | The number of partitions in the search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 and 3. |
| [`privateEndpoints`](#parameter-privateendpoints) | array | Configuration details for private endpoints. For security reasons, it is recommended to use private endpoints whenever possible. |
| [`publicNetworkAccess`](#parameter-publicnetworkaccess) | string | This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. |
| [`publicNetworkAccess`](#parameter-publicnetworkaccess) | string | This value can be set to 'Enabled' to avoid breaking changes on existing customer resources and templates. If set to 'Disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. |
| [`replicaCount`](#parameter-replicacount) | int | The number of replicas in the search service. If specified, it must be a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU. |
| [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignments to create. |
| [`semanticSearch`](#parameter-semanticsearch) | string | Sets options that control the availability of semantic search. This configuration is only possible for certain search SKUs in certain locations. |
Expand Down Expand Up @@ -958,8 +974,7 @@ Configuration details for private endpoints. For security reasons, it is recomme
| [`lock`](#parameter-privateendpointslock) | object | Specify the type of lock. |
| [`manualConnectionRequestMessage`](#parameter-privateendpointsmanualconnectionrequestmessage) | string | A message passed to the owner of the remote resource with the manual connection request. |
| [`name`](#parameter-privateendpointsname) | string | The name of the private endpoint. |
| [`privateDnsZoneGroupName`](#parameter-privateendpointsprivatednszonegroupname) | string | The name of the private DNS zone group to create if `privateDnsZoneResourceIds` were provided. |
| [`privateDnsZoneResourceIds`](#parameter-privateendpointsprivatednszoneresourceids) | array | The private DNS zone groups to associate the private endpoint with. A DNS zone group can support up to 5 DNS zones. |
| [`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. |
| [`roleAssignments`](#parameter-privateendpointsroleassignments) | array | Array of role assignments to create. |
Expand Down Expand Up @@ -1143,19 +1158,64 @@ The name of the private endpoint.
- Required: No
- Type: string

### Parameter: `privateEndpoints.privateDnsZoneGroupName`
### Parameter: `privateEndpoints.privateDnsZoneGroup`

The private DNS zone group to configure for the private endpoint.

- Required: No
- Type: object

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`privateDnsZoneGroupConfigs`](#parameter-privateendpointsprivatednszonegroupprivatednszonegroupconfigs) | array | The private DNS zone groups to associate the private endpoint. A DNS zone group can support up to 5 DNS zones. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`name`](#parameter-privateendpointsprivatednszonegroupname) | string | The name of the Private DNS Zone Group. |

### Parameter: `privateEndpoints.privateDnsZoneGroup.privateDnsZoneGroupConfigs`

The private DNS zone groups to associate the private endpoint. A DNS zone group can support up to 5 DNS zones.

- Required: Yes
- Type: array

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`privateDnsZoneResourceId`](#parameter-privateendpointsprivatednszonegroupprivatednszonegroupconfigsprivatednszoneresourceid) | string | The resource id of the private DNS zone. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`name`](#parameter-privateendpointsprivatednszonegroupprivatednszonegroupconfigsname) | string | The name of the private DNS zone group config. |

### Parameter: `privateEndpoints.privateDnsZoneGroup.privateDnsZoneGroupConfigs.privateDnsZoneResourceId`

The resource id of the private DNS zone.

- Required: Yes
- Type: string

### Parameter: `privateEndpoints.privateDnsZoneGroup.privateDnsZoneGroupConfigs.name`

The name of the private DNS zone group to create if `privateDnsZoneResourceIds` were provided.
The name of the private DNS zone group config.

- Required: No
- Type: string

### Parameter: `privateEndpoints.privateDnsZoneResourceIds`
### Parameter: `privateEndpoints.privateDnsZoneGroup.name`

The private DNS zone groups to associate the private endpoint with. A DNS zone group can support up to 5 DNS zones.
The name of the Private DNS Zone Group.

- Required: No
- Type: array
- Type: string

### Parameter: `privateEndpoints.privateLinkServiceConnectionName`

Expand Down Expand Up @@ -1284,16 +1344,16 @@ Tags to be applied on all resources/resource groups in this deployment.

### Parameter: `publicNetworkAccess`

This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method.
This value can be set to 'Enabled' to avoid breaking changes on existing customer resources and templates. If set to 'Disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method.

- Required: No
- Type: string
- Default: `'enabled'`
- Default: `'Enabled'`
- Allowed:
```Bicep
[
'disabled'
'enabled'
'Disabled'
'Enabled'
]
```

Expand Down Expand Up @@ -1459,6 +1519,7 @@ Tags to help categorize the resource in the Azure portal.
| :-- | :-- | :-- |
| `location` | string | The location the resource was deployed into. |
| `name` | string | The name of the search service. |
| `privateEndpoints` | array | The private endpoints of the search service. |
| `resourceGroupName` | string | The name of the resource group the search service was created in. |
| `resourceId` | string | The resource ID of the search service. |
| `systemAssignedMIPrincipalId` | string | The principal ID of the system assigned identity. |
Expand All @@ -1469,7 +1530,7 @@ 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.6.1` | Remote reference |
| `br/public:avm/res/network/private-endpoint:0.7.1` | Remote reference |

## Data Collection

Expand Down
49 changes: 33 additions & 16 deletions avm/res/search/search-service/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ param privateEndpoints privateEndpointType
@description('Optional. The sharedPrivateLinkResources to create as part of the search Service.')
param sharedPrivateLinkResources array = []

@description('Optional. This value can be set to \'enabled\' to avoid breaking changes on existing customer resources and templates. If set to \'disabled\', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method.')
@description('Optional. This value can be set to \'Enabled\' to avoid breaking changes on existing customer resources and templates. If set to \'Disabled\', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method.')
@allowed([
'enabled'
'disabled'
'Enabled'
'Disabled'
])
param publicNetworkAccess string = 'enabled'
param publicNetworkAccess string = 'Enabled'

@description('Optional. The number of replicas in the search service. If specified, it must be a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU.')
@minValue(1)
Expand Down Expand Up @@ -158,7 +158,7 @@ var formattedRoleAssignments = [

#disable-next-line no-deployments-resources
resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableTelemetry) {
name: '46d3xbcp.search-searchservice.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name, location), 0, 4)}'
name: '46d3xbcp.res.search-searchservice.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name, location), 0, 4)}'
properties: {
mode: 'Incremental'
template: {
Expand Down Expand Up @@ -193,7 +193,7 @@ resource searchService 'Microsoft.Search/searchServices@2024-03-01-preview' = {
networkRuleSet: networkRuleSet
partitionCount: partitionCount
replicaCount: replicaCount
publicNetworkAccess: publicNetworkAccess
publicNetworkAccess: toLower(publicNetworkAccess)
semanticSearch: semanticSearch
}
}
Expand Down Expand Up @@ -254,7 +254,7 @@ resource searchService_roleAssignments 'Microsoft.Authorization/roleAssignments@
}
]

module searchService_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.6.1' = [
module searchService_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.7.1' = [
for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-searchService-PrivateEndpoint-${index}'
scope: resourceGroup(privateEndpoint.?resourceGroupName ?? '')
Expand Down Expand Up @@ -295,8 +295,7 @@ module searchService_privateEndpoints 'br/public:avm/res/network/private-endpoin
'Full'
).location
lock: privateEndpoint.?lock ?? lock
privateDnsZoneGroupName: privateEndpoint.?privateDnsZoneGroupName
privateDnsZoneResourceIds: privateEndpoint.?privateDnsZoneResourceIds
privateDnsZoneGroup: privateEndpoint.?privateDnsZoneGroup
roleAssignments: privateEndpoint.?roleAssignments
tags: privateEndpoint.?tags ?? tags
customDnsConfigs: privateEndpoint.?customDnsConfigs
Expand All @@ -315,9 +314,7 @@ module searchService_sharedPrivateLinkResources 'shared-private-link-resource/ma
for (sharedPrivateLinkResource, index) in sharedPrivateLinkResources: {
name: '${uniqueString(deployment().name, location)}-searchService-SharedPrivateLink-${index}'
params: {
name: contains(sharedPrivateLinkResource, 'name')
? sharedPrivateLinkResource.name
: 'spl-${last(split(searchService.id, '/'))}-${sharedPrivateLinkResource.groupId}-${index}'
name: sharedPrivateLinkResource.?name ?? 'spl-${last(split(searchService.id, '/'))}-${sharedPrivateLinkResource.groupId}-${index}'
searchServiceName: searchService.name
privateLinkResourceId: sharedPrivateLinkResource.privateLinkResourceId
groupId: sharedPrivateLinkResource.groupId
Expand Down Expand Up @@ -346,6 +343,17 @@ output systemAssignedMIPrincipalId string = searchService.?identity.?principalId
@description('The location the resource was deployed into.')
output location string = searchService.location

@description('The private endpoints of the search service.')
output privateEndpoints array = [
for (pe, i) in (!empty(privateEndpoints) ? array(privateEndpoints) : []): {
name: searchService_privateEndpoints[i].outputs.name
resourceId: searchService_privateEndpoints[i].outputs.resourceId
groupId: searchService_privateEndpoints[i].outputs.groupId
customDnsConfig: searchService_privateEndpoints[i].outputs.customDnsConfig
networkInterfaceIds: searchService_privateEndpoints[i].outputs.networkInterfaceIds
}
]

// =============== //
// Definitions //
// =============== //
Expand Down Expand Up @@ -408,11 +416,20 @@ type privateEndpointType = {
@description('Required. Resource ID of the subnet where the endpoint needs to be created.')
subnetResourceId: string

@description('Optional. The name of the private DNS zone group to create if `privateDnsZoneResourceIds` were provided.')
privateDnsZoneGroupName: string?
@description('Optional. The private DNS zone group to configure for the private endpoint.')
privateDnsZoneGroup: {
@description('Optional. The name of the Private DNS Zone Group.')
name: string?

@description('Required. The private DNS zone groups to associate the private endpoint. A DNS zone group can support up to 5 DNS zones.')
privateDnsZoneGroupConfigs: {
@description('Optional. The name of the private DNS zone group config.')
name: string?

@description('Optional. The private DNS zone groups to associate the private endpoint with. A DNS zone group can support up to 5 DNS zones.')
privateDnsZoneResourceIds: string[]?
@description('Required. The resource id of the private DNS zone.')
privateDnsZoneResourceId: string
}[]
}?

@description('Optional. If Manual Private Link Connection is required.')
isManualConnection: bool?
Expand Down
Loading

0 comments on commit 6df8e94

Please sign in to comment.