Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: New module avm/ptn/mgmt-groups/subscription-placement #3904

Merged
merged 75 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
2e6b4a0
initial commit of sub placement code
31Nick Nov 30, 2024
49d0655
initial commit sub placement module
31Nick Nov 30, 2024
032eb84
create workflow yml
31Nick Nov 30, 2024
01dc88a
update dir name
31Nick Nov 30, 2024
2771a97
rem waf tests
31Nick Nov 30, 2024
f56f77c
update files as per static code test output
31Nick Dec 2, 2024
ab0c8d4
Update README.md
31Nick Dec 2, 2024
1d40839
add further descriptors and outputs
31Nick Dec 2, 2024
d40ac12
Merge branch 'sub-placement-development' of https://github.com/31Nick…
31Nick Dec 2, 2024
2f534bd
update main.test.bicep with static validation recommendations
31Nick Dec 2, 2024
a644714
error resolution from static validation tests
31Nick Dec 2, 2024
1b4bffc
resolve static validation issues
31Nick Dec 2, 2024
8c8e659
add telemetry
31Nick Dec 9, 2024
ff10561
update code owners file
31Nick Dec 9, 2024
503cd68
update serviceshort param
31Nick Dec 9, 2024
bc72d60
change UDT Description
31Nick Dec 9, 2024
6b0a710
update main.json
31Nick Dec 9, 2024
dfd9508
dir restructure
31Nick Dec 9, 2024
60e7f91
update codeowners
31Nick Dec 9, 2024
3f71f9d
Update file structure
oZakari Dec 12, 2024
c0b116b
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
oZakari Dec 12, 2024
256da57
Updating codeowners and workflow
oZakari Dec 12, 2024
ee5e80f
Update params
oZakari Dec 12, 2024
e7d7b51
Minor param and test updates
oZakari Dec 12, 2024
13c4496
Fix workflow name
oZakari Dec 18, 2024
91e2c8a
Fix static test errors
oZakari Dec 18, 2024
4f94615
Update readme
oZakari Dec 18, 2024
3bdde89
Update codeowners file
oZakari Dec 18, 2024
e96094a
Adjust team names
oZakari Dec 18, 2024
7ea092e
Update issue template
oZakari Dec 18, 2024
b541f0d
Create secure params for subscription ids
oZakari Dec 18, 2024
a78da21
Add in secure params
oZakari Dec 18, 2024
7e8957c
Merge branch 'Azure:main' into sub-placement-development
31Nick Dec 18, 2024
5326d6f
update camel casing on customsubscriptionPlacement
31Nick Dec 18, 2024
c423ea7
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
oZakari Dec 18, 2024
eca6071
Update test
oZakari Dec 18, 2024
84cf5eb
Testing using variable
oZakari Dec 18, 2024
fb8098c
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
oZakari Jan 9, 2025
97cf15f
Merge branch 'main' into sub-placement-development
oZakari Jan 10, 2025
25d5ab8
Update parameter names
oZakari Jan 13, 2025
db34d0c
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
oZakari Jan 17, 2025
19b3c5d
Update readme
oZakari Jan 17, 2025
0021464
Update deployment name
oZakari Jan 17, 2025
dcf2b13
Fix json file
oZakari Jan 17, 2025
11c8818
Include logic to create mgmt group and subscription
oZakari Jan 27, 2025
7b4c58d
Update deployment name
oZakari Jan 27, 2025
cf1e36f
FIx deployment
oZakari Jan 27, 2025
1e8aebf
Fix duplicate output
oZakari Jan 27, 2025
00fc744
Update test
oZakari Jan 27, 2025
45e43a3
Update tests
oZakari Jan 27, 2025
b880f9c
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
oZakari Jan 27, 2025
e5554d3
Update readme
oZakari Jan 27, 2025
827cc02
Remove spacing in display name
oZakari Jan 27, 2025
362b472
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
oZakari Feb 3, 2025
2a68eb2
Fix description
oZakari Feb 3, 2025
1a4b063
Fix test
oZakari Feb 3, 2025
cbb0bb7
Fix output
oZakari Feb 3, 2025
5ce5c64
Fix name
oZakari Feb 3, 2025
f8a514d
Reset change
oZakari Feb 3, 2025
7dbdf9a
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
oZakari Feb 12, 2025
dda4fb4
Updating tests
oZakari Feb 12, 2025
b24047f
Adding cleanup to test
oZakari Feb 12, 2025
e69df5f
Update variable
oZakari Feb 12, 2025
1e31ce2
Adding check
oZakari Feb 12, 2025
ddcf9a1
Testing another cleanup approach
oZakari Feb 12, 2025
3afdaf6
Use lz-vending mgmt for cleanup
oZakari Feb 12, 2025
5823705
Get rid of warning
oZakari Feb 12, 2025
38ae888
Update json
oZakari Feb 12, 2025
83f06b0
Test change
oZakari Feb 12, 2025
45b46c4
Update avm/ptn/mgmt-groups/subscription-placement/main.bicep
oZakari Feb 13, 2025
f758b55
Update avm/ptn/mgmt-groups/subscription-placement/tests/e2e/defaults/…
oZakari Feb 13, 2025
418b714
Update avm/ptn/mgmt-groups/subscription-placement/tests/e2e/defaults/…
oZakari Feb 13, 2025
d5dce0b
Update avm/ptn/mgmt-groups/subscription-placement/modules/helper.bicep
oZakari Feb 13, 2025
e67776d
Update avm/ptn/mgmt-groups/subscription-placement/main.bicep
oZakari Feb 13, 2025
90e3631
Merge branch 'main' into sub-placement-development
oZakari Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
/avm/ptn/dev-ops/cicd-agents-and-runners/ @Azure/avm-ptn-devops-cicdagentsandrunners-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/finops-toolkit/finops-hub/ @Azure/avm-ptn-finopstoolkit-finopshub-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/lz/sub-vending/ @Azure/avm-ptn-lz-subvending-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/mgmt-groups/subscription-placement/ @Azure/avm-ptn-mgmtgroups-subscriptionplacement-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/network/hub-networking/ @Azure/avm-ptn-network-hubnetworking-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/network/private-link-private-dns-zones/ @Azure/avm-ptn-network-privatelinkprivatednszones-module-owners-bicep @Azure/avm-module-reviewers-bicep
/avm/ptn/policy-insights/remediation/ @Azure/avm-ptn-policyinsights-remediation-module-owners-bicep @Azure/avm-module-reviewers-bicep
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/avm_module_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ body:
- "avm/ptn/dev-ops/cicd-agents-and-runners"
- "avm/ptn/finops-toolkit/finops-hub"
- "avm/ptn/lz/sub-vending"
- "avm/ptn/mgmt-groups/subscription-placement"
- "avm/ptn/network/hub-networking"
- "avm/ptn/network/private-link-private-dns-zones"
- "avm/ptn/policy-insights/remediation"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "avm.ptn.mgmt-groups.subscription-placement"

on:
workflow_dispatch:
inputs:
staticValidation:
type: boolean
description: "Execute static validation"
required: false
default: true
deploymentValidation:
type: boolean
description: "Execute deployment validation"
required: false
default: true
removeDeployment:
type: boolean
description: "Remove deployed module"
required: false
default: true
push:
branches:
- main
paths:
- ".github/actions/templates/avm-**"
- ".github/workflows/avm.template.module.yml"
- ".github/workflows/avm.ptn.mgmt-groups.subscription-placement.yml"
- "avm/ptn/lz/sub-placement/**"
- "avm/utilities/pipelines/**"
- "!avm/utilities/pipelines/platform/**"
- "!*/**/README.md"

env:
modulePath: "avm/ptn/mgmt-groups/subscription-placement"
workflowPath: ".github/workflows/avm.ptn.mgmt-groups.subscription-placement.yml"

concurrency:
group: ${{ github.workflow }}

jobs:
###########################
# Initialize pipeline #
###########################
job_initialize_pipeline:
runs-on: ubuntu-latest
name: "Initialize pipeline"
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Set input parameters to output variables"
id: get-workflow-param
uses: ./.github/actions/templates/avm-getWorkflowInput
with:
workflowPath: "${{ env.workflowPath}}"
- name: "Get module test file paths"
id: get-module-test-file-paths
uses: ./.github/actions/templates/avm-getModuleTestFiles
with:
modulePath: "${{ env.modulePath }}"
outputs:
workflowInput: ${{ steps.get-workflow-param.outputs.workflowInput }}
moduleTestFilePaths: ${{ steps.get-module-test-file-paths.outputs.moduleTestFilePaths }}
psRuleModuleTestFilePaths: ${{ steps.get-module-test-file-paths.outputs.psRuleModuleTestFilePaths }}
modulePath: "${{ env.modulePath }}"

##############################
# Call reusable workflow #
##############################
call-workflow-passing-data:
name: "Run"
permissions:
id-token: write # For OIDC
contents: write # For release tags
needs:
- job_initialize_pipeline
uses: ./.github/workflows/avm.template.module.yml
with:
workflowInput: "${{ needs.job_initialize_pipeline.outputs.workflowInput }}"
moduleTestFilePaths: "${{ needs.job_initialize_pipeline.outputs.moduleTestFilePaths }}"
psRuleModuleTestFilePaths: "${{ needs.job_initialize_pipeline.outputs.psRuleModuleTestFilePaths }}"
modulePath: "${{ needs.job_initialize_pipeline.outputs.modulePath}}"
secrets: inherit
170 changes: 170 additions & 0 deletions avm/ptn/mgmt-groups/subscription-placement/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# subscription-placement `[MgmtGroups/SubscriptionPlacement]`

This module allows for placement of subscriptions to management groups

## Navigation

- [Resource Types](#Resource-Types)
- [Usage examples](#Usage-examples)
- [Parameters](#Parameters)
- [Outputs](#Outputs)
- [Data Collection](#Data-Collection)

## Resource Types

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.Management/managementGroups/subscriptions` | [2023-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Management/2023-04-01/managementGroups/subscriptions) |

## Usage examples

The following section provides usage examples for the module, which were used to validate and deploy the module successfully. For a full reference, please review the module's test folder in its repository.

>**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order.

>**Note**: To reference the module, please use the following syntax `br/public:avm/ptn/mgmt-groups/subscription-placement:<version>`.

- [Using only defaults.](#example-1-using-only-defaults)

### Example 1: _Using only defaults._

This instance deploys the module with the minimum set of required parameters.


<details>

<summary>via Bicep module</summary>

```bicep
module subscriptionPlacement 'br/public:avm/ptn/mgmt-groups/subscription-placement:<version>' = {
name: 'subscriptionPlacementDeployment'
params: {
parSubscriptionPlacement: [
{
managementGroupId: '<managementGroupId>'
subscriptionIds: [
'<subVendingSubscriptionId>'
]
}
]
}
}
```

</details>
<p>

<details>

<summary>via JSON parameters file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"parSubscriptionPlacement": {
"value": [
{
"managementGroupId": "<managementGroupId>",
"subscriptionIds": [
"<subVendingSubscriptionId>"
]
}
]
}
}
}
```

</details>
<p>

<details>

<summary>via Bicep parameters file</summary>

```bicep-params
using 'br/public:avm/ptn/mgmt-groups/subscription-placement:<version>'

param parSubscriptionPlacement = [
{
managementGroupId: '<managementGroupId>'
subscriptionIds: [
'<subVendingSubscriptionId>'
]
}
]
```

</details>
<p>

## Parameters

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`parSubscriptionPlacement`](#parameter-parsubscriptionplacement) | array | The management group IDs along with the subscriptions to be placed underneath them. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`enableTelemetry`](#parameter-enabletelemetry) | bool | Enable/Disable usage telemetry for module. |
| [`location`](#parameter-location) | string | Location for all resources. |

### Parameter: `parSubscriptionPlacement`

The management group IDs along with the subscriptions to be placed underneath them.

- Required: Yes
- Type: array

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`managementGroupId`](#parameter-parsubscriptionplacementmanagementgroupid) | string | The ID of the management group. |
| [`subscriptionIds`](#parameter-parsubscriptionplacementsubscriptionids) | array | The list of subscription IDs to be placed underneath the management group. |

### Parameter: `parSubscriptionPlacement.managementGroupId`

The ID of the management group.

- Required: Yes
- Type: string

### Parameter: `parSubscriptionPlacement.subscriptionIds`

The list of subscription IDs to be placed underneath the management group.

- Required: Yes
- Type: array

### Parameter: `enableTelemetry`

Enable/Disable usage telemetry for module.

- Required: No
- Type: bool
- Default: `True`

### Parameter: `location`

Location for all resources.

- Required: No
- Type: string
- Default: `[deployment().location]`

## Outputs

| Output | Type | Description |
| :-- | :-- | :-- |
| `subscriptionPlacementSummary` | string | Output of number of management groups that have been configured with subscription placements. |

## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the [repository](https://aka.ms/avm/telemetry). There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
67 changes: 67 additions & 0 deletions avm/ptn/mgmt-groups/subscription-placement/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
targetScope = 'tenant'

metadata name = 'subscription-placement'
metadata description = 'This module allows for placement of subscriptions to management groups '

// ------------------
// PARAMETERS
// ------------------

@description('Required. The management group IDs along with the subscriptions to be placed underneath them.')
param parSubscriptionPlacement subscriptionPlacementType[]

@description('Optional. Location for all resources.')
param location string = deployment().location

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

#disable-next-line no-deployments-resources
resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableTelemetry) {
name: '46d3xbcp.ptn.mgmtgroup-subplacement.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name, location), 0, 4)}'
location: location
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
resources: []
outputs: {
telemetry: {
type: 'String'
value: 'For more information, see https://aka.ms/avm/TelemetryInfo'
}
}
}
}
}

module customSubscriptionPlacement './modules/helper.bicep' = [
for (subscriptionPlacement, index) in parSubscriptionPlacement: {
name: 'subPlacment-${uniqueString(subscriptionPlacement.managementGroupId)}${index}'
params: {
managementGroupId: subscriptionPlacement.managementGroupId
subscriptionIds: subscriptionPlacement.subscriptionIds
}
}
]

// =============== //
// Outputs //
// =============== //

@description('Output of number of management groups that have been configured with subscription placements.')
output subscriptionPlacementSummary string = 'Subscription placements have been configured for ${length(parSubscriptionPlacement)} management groups.'

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

@export()
@description('The type for a subscription placement.')
type subscriptionPlacementType = {
@description('Required. The ID of the management group.')
managementGroupId: string
@description('Required. The list of subscription IDs to be placed underneath the management group.')
subscriptionIds: string[]
}
Loading