Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
0778370
test msi out
Jan 14, 2022
d2f52f5
comment pipeline jobs
Jan 14, 2022
e1a42ae
test live token replacement
Jan 14, 2022
10b3f33
LocalCustomParameterFileTokens
Jan 14, 2022
a8a8d96
remove get step
Jan 14, 2022
dcb1754
array 2
Jan 14, 2022
5729e4c
remove local token param
Jan 14, 2022
01ebf77
replace all hardcoded msi obj id
Jan 16, 2022
86623d7
single list token
Jan 16, 2022
d2c22f9
single list token array
Jan 16, 2022
bd0f512
single list token OtherCustomParameterFileTokens
Jan 16, 2022
9648465
replace msi principal id in kv dep
Jan 16, 2022
1c3e446
replace msi principal id in kv sql and rsv dep
Jan 16, 2022
012b23a
all dep back
Jan 16, 2022
30fc91f
a
Jan 16, 2022
d424cec
ado pipeline
Jan 16, 2022
22b4ea4
Load used functions
Jan 16, 2022
5d8bfd2
access out
Jan 16, 2022
eff019e
access out quotes
Jan 16, 2022
1bd2be3
replace token ado
Jan 17, 2022
3a35a2b
replace token ado next stage
Jan 17, 2022
12bd0b3
param path
Jan 17, 2022
97c33e1
rolea displayname
Jan 17, 2022
6eaef45
rolea displayname msi
Jan 17, 2022
5aed5b3
ado action input
Jan 17, 2022
89b8d03
custom token to json
Jan 17, 2022
0196027
custom token to json var
Jan 17, 2022
056b768
custom token print
Jan 17, 2022
a54dcb5
customParameterFileTokens
Jan 17, 2022
783d187
customParameterFileTokens deploymentBlock
Jan 17, 2022
777a86f
customParameterFileTokens deploymentBlock print
Jan 17, 2022
38f5cef
msi prin id print
Jan 17, 2022
e61e0fb
msi prin id print var job
Jan 17, 2022
6700736
msi prin id print var job quotes
Jan 17, 2022
06959b9
test print msi
Jan 17, 2022
da35a2a
test print msi in template
Jan 17, 2022
6ec46a6
test print msi in template quotes
Jan 17, 2022
28aa9f8
template var
Jan 17, 2022
9baaf0f
template var print double
Jan 17, 2022
e4ee3b0
template var print
Jan 17, 2022
49443dd
template var up
Jan 17, 2022
cf2da54
template var up escape
Jan 17, 2022
0dc2915
stage var
Jan 17, 2022
bda1674
stage var
Jan 17, 2022
c1847a1
concat
Jan 17, 2022
90d74ee
msi stage var
Jan 17, 2022
76e8813
multiline value
Jan 17, 2022
167758b
sq brac
Jan 17, 2022
b728ee6
stageDependencies
Jan 17, 2022
66a0f0e
sq brac 1 pair
Jan 17, 2022
432e61d
sq brac 1 pair quotes
Jan 17, 2022
922bee2
sq brac 1 pair quotes escape
Jan 17, 2022
2e41cd2
sq brac 1 pair 2 quotes escape
Jan 17, 2022
321c789
write verbose single quote
Jan 17, 2022
7ea1749
write verbose single quote
Jan 17, 2022
808538c
single quote param
Jan 17, 2022
33c2bc1
single quote param var
Jan 17, 2022
4a93cb4
OtherCustomParameterFileTokens
Jan 17, 2022
4fb5956
OtherCustomParameterFileTokens in second stage
Jan 17, 2022
a76b97f
cleanup
Jan 17, 2022
4f17321
cleanup template
Jan 17, 2022
a8bb431
all jobs using msi id
Jan 17, 2022
99c1be8
comment not used stages
Jan 17, 2022
a1bd9bc
gh alternative
Jan 17, 2022
646a238
gh alternative all
Jan 17, 2022
a9b5219
gh dep all back
Jan 17, 2022
066b2b8
ado dep all back
Jan 17, 2022
3bf2856
ado dep all back cleanup
Jan 17, 2022
0670a90
Update .github/workflows/platform.dependencies.yml
eriqua Jan 19, 2022
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
5 changes: 5 additions & 0 deletions .azuredevops/pipelineTemplates/module.jobs.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,15 @@ jobs:
@{ Name = "deploymentSpId"; Value = '$(DEPLOYMENT_SP_ID)' }
) | ForEach-Object { [PSCustomObject]$PSItem }

# Get additional Custom Parameter File Tokens from input
Write-Verbose 'Additional Custom Parameter File Tokens: ${{ deploymentBlock.customParameterFileTokens }}' -Verbose
$OtherCustomParameterFileTokens = '${{ deploymentBlock.customParameterFileTokens }}' | ConvertFrom-Json

# Construct Token Function Input
$ConvertTokensInputs = @{
ParameterFilePath = Join-Path '$(parametersRepoRoot)' '${{ deploymentBlock.path }}'
DefaultParameterFileTokens = $DefaultParameterFileTokens
OtherCustomParameterFileTokens = $OtherCustomParameterFileTokens
LocalCustomParameterFileTokens = $Settings.parameterFileTokens.localTokens.tokens
TokenPrefix = $Settings.parameterFileTokens.tokenPrefix
TokenSuffix = $Settings.parameterFileTokens.tokenSuffix
Expand Down
35 changes: 34 additions & 1 deletion .azuredevops/platformPipelines/platform.dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ stages:
- path: $(dependencyPath)/$(resourceType)/parameters/parameters.json
templateFilePath: $(templateFilePath)
displayName: User Assigned Identity
jobName: job_deploy_msi
- job: job_set_msi_id
displayName: Set msi principal ID output
dependsOn:
- job_deploy_msi
pool:
${{ if eq(variables['vmImage'], '') }}:
name: $(poolName)
${{ if eq(variables['poolName'], '') }}:
vmImage: $(vmImage)
variables:
deploymentOutput: $[ dependencies.job_deploy_msi.outputs['DeployModule.deploymentOutput'] ]
steps:
- task: PowerShell@2
name: print_msi_prinId
inputs:
targetType: inline
pwsh: true
script: |
# Write-Verbose $(deploymentOutput) -Verbose
$msiPrincipalId = (ConvertFrom-Json '$(deploymentOutput)').msiPrincipalId
Write-Verbose "msiPrincipalId: $msiPrincipalId" -Verbose
Write-Output ('##vso[task.setvariable variable={0};isOutput=true]{1}' -f 'msiPrincipalId', $msiPrincipalId)

- stage: deploy_pa
displayName: Deploy policy assignment
Expand Down Expand Up @@ -355,26 +378,31 @@ stages:
- deploy_sa
- deploy_evh
- deploy_law
- deploy_msi
variables:
resourceType: 'Microsoft.RecoveryServices/vaults'
templateFilePath: $(modulesPath)/$(resourceType)/deploy.bicep
msiPrincipalId: $[ stageDependencies.deploy_msi.job_set_msi_id.outputs['print_msi_prinId.msiPrincipalId'] ]
jobs:
- template: /.azuredevops/pipelineTemplates/module.jobs.deploy.yml
parameters:
deploymentBlocks:
- path: $(dependencyPath)/$(resourceType)/parameters/parameters.json
templateFilePath: $(templateFilePath)
displayName: Default recovery services vault
customParameterFileTokens: '[{"Name":"msiPrincipalId","Value":"$(msiPrincipalId)"}]'

- stage: deploy_kv
displayName: Deploy key vaults
dependsOn:
- deploy_sa
- deploy_evh
- deploy_law
- deploy_msi
variables:
resourceType: 'Microsoft.KeyVault/vaults'
templateFilePath: $(modulesPath)/$(resourceType)/deploy.bicep
msiPrincipalId: $[ stageDependencies.deploy_msi.job_set_msi_id.outputs['print_msi_prinId.msiPrincipalId'] ]
jobs:
- template: /.azuredevops/pipelineTemplates/module.jobs.deploy.yml
parameters:
Expand All @@ -383,14 +411,17 @@ stages:
templateFilePath: $(templateFilePath)
displayName: Default Key Vault
jobName: default_kv
customParameterFileTokens: '[{"Name":"msiPrincipalId","Value":"$(msiPrincipalId)"}]'
- path: $(dependencyPath)/$(resourceType)/parameters/pe.parameters.json
templateFilePath: $(templateFilePath)
displayName: Private Endpoint Key Vault
customParameterFileTokens: '[{"Name":"msiPrincipalId","Value":"$(msiPrincipalId)"}]'
- ${{ if eq( parameters.deploySqlMiDependencies, true) }}:
- path: $(dependencyPath)/$(resourceType)/parameters/sqlmi.parameters.json
templateFilePath: $(templateFilePath)
displayName: SQLMI key vault
jobName: sqlmi_kv
customParameterFileTokens: '[{"Name":"msiPrincipalId","Value":"$(msiPrincipalId)"}]'
- job:
displayName: Set key vault secrets keys and certificates
dependsOn:
Expand Down Expand Up @@ -558,15 +589,17 @@ stages:
dependsOn:
- deploy_msi
variables:
resourceType: 'Microsoft.Authorization\roleAssignments'
resourceType: 'Microsoft.Authorization/roleAssignments'
templateFilePath: $(modulesPath)/$(resourceType)/.bicep/nested_rbac_sub.bicep
msiPrincipalId: $[ stageDependencies.deploy_msi.job_set_msi_id.outputs['print_msi_prinId.msiPrincipalId'] ]
jobs:
- template: /.azuredevops/pipelineTemplates/module.jobs.deploy.yml
parameters:
deploymentBlocks:
- path: $(dependencyPath)/$(resourceType)/parameters/parameters.json
templateFilePath: $(templateFilePath)
displayName: MSI Role Assignment
customParameterFileTokens: '[{"Name":"msiPrincipalId","Value":"$(msiPrincipalId)"}]'

- stage: deploy_vnet
displayName: Deploy virtual networks
Expand Down
10 changes: 8 additions & 2 deletions .github/actions/templates/validateModuleDeployment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
managementGroupId:
description: 'The managementGroupId to deploy to'
required: false
customParameterFileTokens:
description: 'Additional parameter file token pairs in json format. e.g. [{"Name":"tokenName","Value":"tokenValue"}]'
required: false
removeDeployment:
description: 'Set "true" to set module up for removal'
default: 'true'
Expand Down Expand Up @@ -84,14 +87,17 @@ runs:
@{ Name = 'managementGroupId'; Value = '${{ inputs.managementGroupId }}' }
@{ Name = "tenantId"; Value = '${{ env.ARM_TENANT_ID }}' }
@{ Name = "deploymentSpId"; Value = '${{ env.DEPLOYMENT_SP_ID }}' }
)
) | ForEach-Object { [PSCustomObject]$PSItem }

$DefaultParameterFileTokens = $DefaultParameterFileTokens | ForEach-Object { [PSCustomObject]$PSItem }
# Get additional Custom Parameter File Tokens from input
Write-Verbose 'Additional Custom Parameter File Tokens: ${{ inputs.customParameterFileTokens }}' -Verbose
$OtherCustomParameterFileTokens = '${{ inputs.customParameterFileTokens }}' | ConvertFrom-Json

# Construct Token Function Input
$ConvertTokensInputs = @{
ParameterFilePath = '${{ inputs.parameterFilePath }}'
DefaultParameterFileTokens = $DefaultParameterFileTokens
OtherCustomParameterFileTokens = $OtherCustomParameterFileTokens
LocalCustomParameterFileTokens = $Settings.parameterFileTokens.localTokens.tokens
TokenPrefix = $Settings.parameterFileTokens.tokenPrefix
TokenSuffix = $Settings.parameterFileTokens.tokenSuffix
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/platform.dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ jobs:
namespace: 'Microsoft.ManagedIdentity\userAssignedIdentities'
needs:
- job_deploy_rg
outputs:
msiPrincipalId: ${{ steps.print_msi_prinId.outputs.msiPrincipalId }}
strategy:
fail-fast: false
matrix:
Expand All @@ -72,6 +74,7 @@ jobs:
with:
fetch-depth: 0
- name: 'Deploy module'
id: deploy_msi
uses: ./.github/actions/templates/validateModuleDeployment
with:
templateFilePath: 'arm/${{ env.namespace }}/deploy.bicep'
Expand All @@ -81,6 +84,15 @@ jobs:
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ env.removeDeployment }}'
- name: Set msi principal ID output
id: print_msi_prinId
uses: azure/powershell@v1
with:
inlineScript: |
$deploymentOutput = '${{ steps.deploy_msi.outputs.deploymentOutput }}'
$msiPrincipalId = (ConvertFrom-Json $deploymentOutput).msiPrincipalId
Write-Output ('::set-output name={0}::{1}' -f 'msiPrincipalId', $msiPrincipalId)
azPSVersion: 'latest'

job_deploy_pa:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -573,6 +585,7 @@ jobs:
- job_deploy_sa
- job_deploy_evh
- job_deploy_law
- job_deploy_msi
strategy:
fail-fast: false
matrix:
Expand All @@ -592,6 +605,7 @@ jobs:
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ env.removeDeployment }}'
customParameterFileTokens: '[{"Name":"msiPrincipalId","Value":"${{ needs.job_deploy_msi.outputs.msiPrincipalId }}"}]'

job_deploy_kv:
runs-on: ubuntu-20.04
Expand All @@ -602,6 +616,7 @@ jobs:
- job_deploy_sa
- job_deploy_evh
- job_deploy_law
- job_deploy_msi
strategy:
fail-fast: false
matrix:
Expand All @@ -621,6 +636,7 @@ jobs:
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ env.removeDeployment }}'
customParameterFileTokens: '[{"Name":"msiPrincipalId","Value":"${{ needs.job_deploy_msi.outputs.msiPrincipalId }}"}]'

job_deploy_kv_secrets:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -714,6 +730,7 @@ jobs:
- job_deploy_sa
- job_deploy_evh
- job_deploy_law
- job_deploy_msi
strategy:
fail-fast: false
matrix:
Expand All @@ -733,6 +750,7 @@ jobs:
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ env.removeDeployment }}'
customParameterFileTokens: '[{"Name":"msiPrincipalId","Value":"${{ needs.job_deploy_msi.outputs.msiPrincipalId }}"}]'

job_deploy_sqlmi_kv_secrets:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -853,6 +871,7 @@ jobs:
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ env.removeDeployment }}'
customParameterFileTokens: '[{"Name":"msiPrincipalId","Value":"${{ needs.job_deploy_msi.outputs.msiPrincipalId }}"}]'

job_deploy_vnet:
runs-on: ubuntu-20.04
Expand Down
4 changes: 2 additions & 2 deletions docs/wiki/TestingDesign.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ Since also dependency resources are in turn subject to dependencies with each ot

**Second level resources**: This group of resources has a dependency only on the resource group which will host them. Resources in this group can be deployed in parallel.

1. User assigned identity: This resource is leveraged by all dependency resources
> **Note**: The object ID of the [user assigned identity] must be set in several dependency parameter files. However, when you first run the pipeline, this object ID will be unknown. It is hence recommended to either manually create the MSI beforehand - or - run the pipeline without the ID once (which will cause the pipeline to fail during the ID's usage, but **after** the MSI was deployed), then update the value in the parameter files and finally re-run the pipeline.
1. User assigned identity: This resource is leveraged by the [role assignment], [key vault] and [recovery services vault] dependency resources.
> **Note**: The object ID of the [user assigned identity] is needed by several dependency parameter files. However, before running the dependency pipeline for the first time, the [user assigned identity] resource does not exist yet, thus its object ID is unknown. For this reason, instead of the object ID value, some dependency parameter files contain the `"<<msiPrincipalId>>"` token, for which the correct value is retrieved and replaced by the pipeline at runtime.
1. Policy assignment: This resource is leveraged by the [policy exemption] resource.
1. Log analytics workspace: This resource is leveraged by all resources supporting diagnostic settings on LAW.
1. Storage account: This resource is leveraged by all resources supporting diagnostic settings on a storage account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"value": "Contributor"
},
"principalId": {
"value": "cf33fea8-b30f-424f-ab73-c48d99e0b222" // The object ID of the deployed MSI
"value": "<<msiPrincipalID>>" // The object ID of the deployed MSI. Replaced by the pipeline
},
"subscriptionId": {
"value": "<<subscriptionId>>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"tenantId": "<<tenantId>>",
"objectId": "cf33fea8-b30f-424f-ab73-c48d99e0b222", // adding adp-sxx-az-msi-x-001 to get secrets
"objectId": "<<msiPrincipalID>>", // The object ID of the deployed MSI. Replaced by the pipeline
"permissions": {
"keys": [],
"secrets": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"value": [
{
"tenantId": "<<tenantId>>",
"objectId": "cf33fea8-b30f-424f-ab73-c48d99e0b222", // adding adp-sxx-az-msi-x-001 to get secrets
"objectId": "<<msiPrincipalID>>", // The object ID of the deployed MSI. Replaced by the pipeline
"permissions": {
"keys": [],
"secrets": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"tenantId": "<<tenantId>>",
"objectId": "cf33fea8-b30f-424f-ab73-c48d99e0b222", // adding adp-sxx-az-msi-x-001 to get secrets
"objectId": "<<msiPrincipalID>>", // The object ID of the deployed MSI. Replaced by the pipeline
"permissions": {
"keys": [
"Get",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
{
"roleDefinitionIdOrName": "Reader",
"principalIds": [
"cf33fea8-b30f-424f-ab73-c48d99e0b222" // The object ID of the deployed MSI
"<<msiPrincipalID>>" // The object ID of the deployed MSI. Replaced by the pipeline
]
}
]
Expand Down