Skip to content

Commit

Permalink
feat: Add Sub & RG Scope support for MG scoped Policy Assignments (#3921
Browse files Browse the repository at this point in the history
)

## Description

Add Sub & RG Scope support for MG scoped Policy Assignments

## Pipeline Reference

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

| Pipeline |
| -------- |
|
[![avm.ptn.authorization.policy-assignment](https://github.com/jtracey93/bicep-registry-modules/actions/workflows/avm.ptn.authorization.policy-assignment.yml/badge.svg?branch=users%2Fjtracey93%2Ffeat%2Fadd-sub-rg-scope-support)](https://github.com/jtracey93/bicep-registry-modules/actions/workflows/avm.ptn.authorization.policy-assignment.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

- [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
jtracey93 authored Dec 11, 2024
1 parent eb9065c commit b23659a
Show file tree
Hide file tree
Showing 10 changed files with 574 additions and 18 deletions.
46 changes: 43 additions & 3 deletions avm/ptn/authorization/policy-assignment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ module policyAssignment 'br/public:avm/ptn/authorization/policy-assignment:<vers
additionalManagementGroupsIDsToAssignRbacTo: [
'<name>'
]
additionalResourceGroupResourceIDsToAssignRbacTo: [
'<resourceId>'
]
additionalSubscriptionIDsToAssignRbacTo: [
'<subscriptionId>'
]
description: '[Description] Policy Assignment at the management group scope'
displayName: '[Display Name] Policy Assignment at the management group scope'
enforcementMode: 'DoNotEnforce'
Expand All @@ -149,7 +155,7 @@ module policyAssignment 'br/public:avm/ptn/authorization/policy-assignment:<vers
}
]
notScopes: [
'/subscriptions/<value>/resourceGroups/validation-rg'
'<resourceId>'
]
overrides: [
{
Expand Down Expand Up @@ -225,6 +231,16 @@ module policyAssignment 'br/public:avm/ptn/authorization/policy-assignment:<vers
"<name>"
]
},
"additionalResourceGroupResourceIDsToAssignRbacTo": {
"value": [
"<resourceId>"
]
},
"additionalSubscriptionIDsToAssignRbacTo": {
"value": [
"<subscriptionId>"
]
},
"description": {
"value": "[Description] Policy Assignment at the management group scope"
},
Expand Down Expand Up @@ -259,7 +275,7 @@ module policyAssignment 'br/public:avm/ptn/authorization/policy-assignment:<vers
},
"notScopes": {
"value": [
"/subscriptions/<value>/resourceGroups/validation-rg"
"<resourceId>"
]
},
"overrides": {
Expand Down Expand Up @@ -336,6 +352,12 @@ param policyDefinitionId = '/providers/Microsoft.Authorization/policySetDefiniti
param additionalManagementGroupsIDsToAssignRbacTo = [
'<name>'
]
param additionalResourceGroupResourceIDsToAssignRbacTo = [
'<resourceId>'
]
param additionalSubscriptionIDsToAssignRbacTo = [
'<subscriptionId>'
]
param description = '[Description] Policy Assignment at the management group scope'
param displayName = '[Display Name] Policy Assignment at the management group scope'
param enforcementMode = 'DoNotEnforce'
Expand All @@ -353,7 +375,7 @@ param nonComplianceMessages = [
}
]
param notScopes = [
'/subscriptions/<value>/resourceGroups/validation-rg'
'<resourceId>'
]
param overrides = [
{
Expand Down Expand Up @@ -1179,6 +1201,8 @@ param userAssignedIdentityId = '<userAssignedIdentityId>'
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`additionalManagementGroupsIDsToAssignRbacTo`](#parameter-additionalmanagementgroupsidstoassignrbacto) | array | An array of additional management group IDs to assign RBAC to for the policy assignment if it has an identity. |
| [`additionalResourceGroupResourceIDsToAssignRbacTo`](#parameter-additionalresourcegroupresourceidstoassignrbacto) | array | An array of additional Resource Group Resource IDs to assign RBAC to for the policy assignment if it has an identity, only supported for Management Group Policy Assignments. |
| [`additionalSubscriptionIDsToAssignRbacTo`](#parameter-additionalsubscriptionidstoassignrbacto) | array | An array of additional Subscription IDs to assign RBAC to for the policy assignment if it has an identity, only supported for Management Group Policy Assignments. |
| [`description`](#parameter-description) | string | This message will be part of response in case of policy violation. |
| [`displayName`](#parameter-displayname) | string | The display name of the policy assignment. Maximum length is 128 characters. |
| [`enableTelemetry`](#parameter-enabletelemetry) | bool | Enable/Disable usage telemetry for module. |
Expand Down Expand Up @@ -1219,6 +1243,22 @@ An array of additional management group IDs to assign RBAC to for the policy ass
- Type: array
- Default: `[]`

### Parameter: `additionalResourceGroupResourceIDsToAssignRbacTo`

An array of additional Resource Group Resource IDs to assign RBAC to for the policy assignment if it has an identity, only supported for Management Group Policy Assignments.

- Required: No
- Type: array
- Default: `[]`

### Parameter: `additionalSubscriptionIDsToAssignRbacTo`

An array of additional Subscription IDs to assign RBAC to for the policy assignment if it has an identity, only supported for Management Group Policy Assignments.

- Required: No
- Type: array
- Default: `[]`

### Parameter: `description`

This message will be part of response in case of policy violation.
Expand Down
8 changes: 8 additions & 0 deletions avm/ptn/authorization/policy-assignment/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ param managementGroupId string = managementGroup().name
@sys.description('Optional. An array of additional management group IDs to assign RBAC to for the policy assignment if it has an identity.')
param additionalManagementGroupsIDsToAssignRbacTo array = []

@sys.description('Optional. An array of additional Subscription IDs to assign RBAC to for the policy assignment if it has an identity, only supported for Management Group Policy Assignments.')
param additionalSubscriptionIDsToAssignRbacTo array = []

@sys.description('Optional. An array of additional Resource Group Resource IDs to assign RBAC to for the policy assignment if it has an identity, only supported for Management Group Policy Assignments.')
param additionalResourceGroupResourceIDsToAssignRbacTo array = []

@sys.description('Optional. The Target Scope for the Policy. The subscription ID of the subscription for the policy assignment.')
param subscriptionId string = ''

Expand Down Expand Up @@ -117,6 +123,8 @@ module policyAssignment_mg 'modules/management-group.bicep' = if (empty(subscrip
overrides: !empty(overrides) ? overrides : []
resourceSelectors: !empty(resourceSelectors) ? resourceSelectors : []
additionalManagementGroupsIDsToAssignRbacTo: additionalManagementGroupsIDsToAssignRbacTo
additionalSubscriptionIDsToAssignRbacTo: additionalSubscriptionIDsToAssignRbacTo
additionalResourceGroupResourceIDsToAssignRbacTo: additionalResourceGroupResourceIDsToAssignRbacTo
}
}

Expand Down
Loading

0 comments on commit b23659a

Please sign in to comment.