Skip to content

Commit

Permalink
- enables managed identity input
Browse files Browse the repository at this point in the history
- updates versions
- uses common AVM types
  • Loading branch information
ReneHezser committed Oct 23, 2024
1 parent eb1bbb8 commit d12e5a4
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 256 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/avm/utilities/ @Azure/avm-core-team-technical-bicep
/avm/ptn/aca-lza/hosting-environment/ @Azure/avm-ptn-acalza-hostingenvironment-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/ai-platform/baseline/ @Azure/avm-ptn-aiplatform-baseline-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/app/container-job-toolkit/ @Azure/avm-ptn-app-containerjobtoolkit-module-owners-bicep @Azure/avm-ptn-app-containerjobtoolkit-module-contributors-bicep
/avm/ptn/authorization/policy-assignment/ @Azure/avm-ptn-authorization-policyassignment-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/authorization/resource-role-assignment/ @Azure/avm-ptn-authorization-resourceroleassignment-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/authorization/role-assignment/ @Azure/avm-ptn-authorization-roleassignment-module-owners-bicep @Azure/avm-module-reviewers-bicep
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/avm_module_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ body:
- ""
- "avm/ptn/aca-lza/hosting-environment"
- "avm/ptn/ai-platform/baseline"
- "avm/ptn/app/container-job-toolkit"
- "avm/ptn/authorization/policy-assignment"
- "avm/ptn/authorization/resource-role-assignment"
- "avm/ptn/authorization/role-assignment"
Expand Down
90 changes: 0 additions & 90 deletions .github/workflows/avm.ptn.app.container-job-toolkit.yml

This file was deleted.

50 changes: 47 additions & 3 deletions avm/res/signal-r-service/signal-r/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This module deploys a SignalR Service SignalR.
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
| `Microsoft.Network/privateEndpoints` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-11-01/privateEndpoints) |
| `Microsoft.Network/privateEndpoints/privateDnsZoneGroups` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-11-01/privateEndpoints/privateDnsZoneGroups) |
| `Microsoft.SignalRService/signalR` | [2022-02-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.SignalRService/2022-02-01/signalR) |
| `Microsoft.SignalRService/signalR` | [2024-03-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.SignalRService/2024-03-01/signalR) |

## Usage examples

Expand Down Expand Up @@ -128,6 +128,10 @@ module signalR 'br/public:avm/res/signal-r-service/signal-r:<version>' = {
kind: 'CanNotDelete'
name: 'myCustomLockName'
}
managedIdentities: {
systemAssigned: false
userAssignedResourceIds: '<userAssignedResourceIds>'
}
networkAcls: {
defaultAction: 'Allow'
privateEndpoints: [
Expand Down Expand Up @@ -248,6 +252,12 @@ module signalR 'br/public:avm/res/signal-r-service/signal-r:<version>' = {
"name": "myCustomLockName"
}
},
"managedIdentities": {
"value": {
"systemAssigned": false,
"userAssignedResourceIds": "<userAssignedResourceIds>"
}
},
"networkAcls": {
"value": {
"defaultAction": "Allow",
Expand Down Expand Up @@ -362,6 +372,10 @@ param lock = {
kind: 'CanNotDelete'
name: 'myCustomLockName'
}
param managedIdentities = {
systemAssigned: false
userAssignedResourceIds: '<userAssignedResourceIds>'
}
param networkAcls = {
defaultAction: 'Allow'
privateEndpoints: [
Expand Down Expand Up @@ -702,6 +716,7 @@ param tags = {
| [`liveTraceCatagoriesToEnable`](#parameter-livetracecatagoriestoenable) | array | Control permission for data plane traffic coming from public networks while private endpoint is enabled. |
| [`location`](#parameter-location) | string | The location for the resource. |
| [`lock`](#parameter-lock) | object | The lock settings of the service. |
| [`managedIdentities`](#parameter-managedidentities) | object | The managed identity definition for this resource. |
| [`networkAcls`](#parameter-networkacls) | object | Networks ACLs, this value contains IPs to allow and/or Subnet information. Can only be set if the 'SKU' is not 'Free_F1'. For security reasons, it is recommended to set the DefaultAction Deny. |
| [`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 | Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set. |
Expand Down Expand Up @@ -868,6 +883,34 @@ Specify the name of lock.
- Required: No
- Type: string

### Parameter: `managedIdentities`

The managed identity definition for this resource.

- Required: No
- Type: object

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`systemAssigned`](#parameter-managedidentitiessystemassigned) | bool | Enables system assigned managed identity on the resource. |
| [`userAssignedResourceIds`](#parameter-managedidentitiesuserassignedresourceids) | array | The resource ID(s) to assign to the resource. Required if a user assigned identity is used for encryption. |

### Parameter: `managedIdentities.systemAssigned`

Enables system assigned managed identity on the resource.

- Required: No
- Type: bool

### Parameter: `managedIdentities.userAssignedResourceIds`

The resource ID(s) to assign to the resource. Required if a user assigned identity is used for encryption.

- Required: No
- Type: array

### Parameter: `networkAcls`

Networks ACLs, this value contains IPs to allow and/or Subnet information. Can only be set if the 'SKU' is not 'Free_F1'. For security reasons, it is recommended to set the DefaultAction Deny.
Expand Down Expand Up @@ -1176,7 +1219,7 @@ Array of role assignments to create.
- `'Owner'`
- `'Private DNS Zone Contributor'`
- `'Reader'`
- `'Role Based Access Control Administrator (Preview)'`
- `'Role Based Access Control Administrator'`

**Required parameters**

Expand Down Expand Up @@ -1487,14 +1530,15 @@ Upstream templates to enable. For more information, see https://learn.microsoft.
| `privateEndpoints` | array | The private endpoints of the SignalR. |
| `resourceGroupName` | string | The SignalR resource group. |
| `resourceId` | string | The SignalR resource ID. |
| `systemAssignedMIPrincipalId` | string | The principal ID of the system assigned identity. |

## Cross-referenced modules

This section gives you an overview of all local-referenced module files (i.e., other modules that are referenced in this module) and all remote-referenced files (i.e., Bicep modules that are referenced from a Bicep Registry or Template Specs).

| Reference | Type |
| :-- | :-- |
| `br/public:avm/res/network/private-endpoint:0.7.1` | Remote reference |
| `br/public:avm/res/network/private-endpoint:0.8.0` | Remote reference |

## Data Collection

Expand Down
75 changes: 36 additions & 39 deletions avm/res/signal-r-service/signal-r/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ metadata name = 'SignalR Service SignalR'
metadata description = 'This module deploys a SignalR Service SignalR.'
metadata owner = 'Azure/module-maintainers'

// ============== //
// Parameters //
// ============== //

@description('Optional. The location for the resource.')
param location string = resourceGroup().location

Expand Down Expand Up @@ -102,14 +106,35 @@ param upstreamTemplatesToEnable array?
param privateEndpoints privateEndpointType

@description('Optional. The lock settings of the service.')
param lock lockType
param lock lockType?

@description('Optional. Array of role assignments to create.')
param roleAssignments roleAssignmentType
param roleAssignments roleAssignmentType[]?

@description('Optional. Enable/Disable usage telemetry for module.')
param enableTelemetry bool = true

@description('Optional. The managed identity definition for this resource.')
param managedIdentities managedIdentityAllType?

// ============= //
// Variables //
// ============= //

var formattedUserAssignedIdentities = reduce(
map((managedIdentities.?userAssignedResourceIds ?? []), (id) => { '${id}': {} }),
{},
(cur, next) => union(cur, next)
) // Converts the flat array to an object like { '${id1}': {}, '${id2}': {} }
var identity = !empty(managedIdentities)
? {
type: (managedIdentities.?systemAssigned ?? false)
? (!empty(managedIdentities.?userAssignedResourceIds ?? {}) ? 'SystemAssigned,UserAssigned' : 'SystemAssigned')
: (!empty(managedIdentities.?userAssignedResourceIds ?? {}) ? 'UserAssigned' : null)
userAssignedIdentities: !empty(formattedUserAssignedIdentities) ? formattedUserAssignedIdentities : null
}
: null

var liveTraceCatagories = [
for configuration in liveTraceCatagoriesToEnable: {
name: configuration
Expand Down Expand Up @@ -200,7 +225,7 @@ resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableT
}
}

resource signalR 'Microsoft.SignalRService/signalR@2022-02-01' = {
resource signalR 'Microsoft.SignalRService/signalR@2024-03-01' = {
name: name
location: location
kind: kind
Expand All @@ -210,6 +235,7 @@ resource signalR 'Microsoft.SignalRService/signalR@2022-02-01' = {
tier: tier
}
tags: tags
identity: identity
properties: {
cors: {
allowedOrigins: allowedOrigins
Expand Down Expand Up @@ -240,7 +266,7 @@ resource signalR 'Microsoft.SignalRService/signalR@2022-02-01' = {
}
}

module signalR_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.7.1' = [
module signalR_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.8.0' = [
for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-signalR-PrivateEndpoint-${index}'
scope: resourceGroup(privateEndpoint.?resourceGroupName ?? '')
Expand Down Expand Up @@ -331,6 +357,9 @@ output resourceId string = signalR.id
@description('The location the resource was deployed into.')
output location string = signalR.location

@description('The principal ID of the system assigned identity.')
output systemAssignedMIPrincipalId string = signalR.?identity.?principalId ?? ''

@description('The private endpoints of the SignalR.')
output privateEndpoints array = [
for (pe, i) in (!empty(privateEndpoints) ? array(privateEndpoints) : []): {
Expand All @@ -346,39 +375,7 @@ output privateEndpoints array = [
// Definitions //
// =============== //

type lockType = {
@description('Optional. Specify the name of lock.')
name: string?

@description('Optional. Specify the type of lock.')
kind: ('CanNotDelete' | 'ReadOnly' | 'None')?
}?

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

@description('Required. The principal ID of the principal (user/group/identity) to assign the role to.')
principalId: string

@description('Optional. The principal type of the assigned principal ID.')
principalType: ('ServicePrincipal' | 'Group' | 'User' | 'ForeignGroup' | 'Device')?

@description('Optional. The description of the role assignment.')
description: string?

@description('Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase "foo_storage_container".')
condition: string?

@description('Optional. Version of the condition.')
conditionVersion: '2.0'?

@description('Optional. The Resource Id of the delegated managed identity resource.')
delegatedManagedIdentityResourceId: string?
}[]?
import { lockType, roleAssignmentType, managedIdentityAllType } from 'br/public:avm/utl/types/avm-common-types:0.1.0'

type privateEndpointType = {
@description('Optional. The name of the private endpoint.')
Expand Down Expand Up @@ -452,10 +449,10 @@ type privateEndpointType = {
customNetworkInterfaceName: string?

@description('Optional. Specify the type of lock.')
lock: lockType
lock: lockType?

@description('Optional. Array of role assignments to create.')
roleAssignments: roleAssignmentType
roleAssignments: roleAssignmentType[]?

@description('Optional. Tags to be applied on all resources/resource groups in this deployment.')
tags: object?
Expand Down
Loading

0 comments on commit d12e5a4

Please sign in to comment.