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

Concurrent role deployment with PowerShell & GitHub Actions #299

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .github/workflows/0-everything.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ jobs:
- ManagementGroups

name: Roles

strategy:
matrix:
roleName:
- la-vminsights-readonly
- lz-appowner
- lz-netops
- lz-secops
- lz-subowner
fail-fast: false

runs-on: ubuntu-latest
steps:
Expand All @@ -79,6 +89,7 @@ jobs:
run: |
./RunWorkflows.ps1 `
-DeployRoles `
-RoleNames '${{ matrix.roleName }}' `
-EnvironmentName '${{github.event.inputs.environmentName}}' `
-LoginServicePrincipalJson (ConvertTo-SecureString -String '${{secrets.ALZ_CREDENTIALS}}' -AsPlainText -Force) `
-GitHubRepo ${env:GITHUB_REPOSITORY} `
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/2-roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ defaults:
jobs:
roles:
name: Roles

strategy:
matrix:
roleName:
- la-vminsights-readonly
- lz-appowner
- lz-netops
- lz-secops
- lz-subowner
fail-fast: false

runs-on: ubuntu-latest
steps:

Expand All @@ -40,6 +51,7 @@ jobs:
run: |
./RunWorkflows.ps1 `
-DeployRoles `
-RoleNames '${{ matrix.roleName }}' `
-EnvironmentName '${{github.event.inputs.environmentName}}' `
-LoginServicePrincipalJson (ConvertTo-SecureString -String '${{secrets.ALZ_CREDENTIALS}}' -AsPlainText -Force) `
-GitHubRepo ${env:GITHUB_REPOSITORY} `
Expand Down
2 changes: 1 addition & 1 deletion roles/la-vminsights-readonly.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var roleDescription = 'Read only access to Log Analytics for VM Insights.'
// Reference: https://docs.microsoft.com/azure/marketplace/azure-partner-customer-usage-attribution
var telemetry = json(loadTextContent('../config/telemetry.json'))
module telemetryCustomerUsageAttribution '../azresources/telemetry/customer-usage-attribution-management-group.bicep' = if (telemetry.customerUsageAttribution.enabled) {
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}'
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}-lavminsightsreadonly'
}

resource roleDefn 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' = {
Expand Down
2 changes: 1 addition & 1 deletion roles/lz-appowner.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var roleDescription = 'Contributor role granted for application/operations team
// Reference: https://docs.microsoft.com/azure/marketplace/azure-partner-customer-usage-attribution
var telemetry = json(loadTextContent('../config/telemetry.json'))
module telemetryCustomerUsageAttribution '../azresources/telemetry/customer-usage-attribution-management-group.bicep' = if (telemetry.customerUsageAttribution.enabled) {
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}'
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}-lzappowner'
}

// Reference: https://docs.microsoft.com/azure/cloud-adoption-framework/ready/landing-zone/design-area/identity-access
Expand Down
2 changes: 1 addition & 1 deletion roles/lz-netops.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var roleDescription = 'Platform-wide global connectivity management: virtual net
// Reference: https://docs.microsoft.com/azure/marketplace/azure-partner-customer-usage-attribution
var telemetry = json(loadTextContent('../config/telemetry.json'))
module telemetryCustomerUsageAttribution '../azresources/telemetry/customer-usage-attribution-management-group.bicep' = if (telemetry.customerUsageAttribution.enabled) {
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}'
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}-lznetops'
}

// Reference: https://docs.microsoft.com/azure/cloud-adoption-framework/ready/landing-zone/design-area/identity-access
Expand Down
2 changes: 1 addition & 1 deletion roles/lz-secops.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var roleDescription = 'Security Administrator role with a horizontal view across
// Reference: https://docs.microsoft.com/azure/marketplace/azure-partner-customer-usage-attribution
var telemetry = json(loadTextContent('../config/telemetry.json'))
module telemetryCustomerUsageAttribution '../azresources/telemetry/customer-usage-attribution-management-group.bicep' = if (telemetry.customerUsageAttribution.enabled) {
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}'
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}-lzsecops'
}

// Reference: https://docs.microsoft.com/azure/cloud-adoption-framework/ready/landing-zone/design-area/identity-access
Expand Down
2 changes: 1 addition & 1 deletion roles/lz-subowner.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var roleDescription = 'Delegated role for subscription owner generated from subs
// Reference: https://docs.microsoft.com/azure/marketplace/azure-partner-customer-usage-attribution
var telemetry = json(loadTextContent('../config/telemetry.json'))
module telemetryCustomerUsageAttribution '../azresources/telemetry/customer-usage-attribution-management-group.bicep' = if (telemetry.customerUsageAttribution.enabled) {
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}'
name: 'pid-${telemetry.customerUsageAttribution.modules.roles}-lzsubowner'
}

// Reference: https://docs.microsoft.com/azure/cloud-adoption-framework/ready/landing-zone/design-area/identity-access
Expand Down
11 changes: 8 additions & 3 deletions scripts/deployments/Functions/Roles.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function Set-Roles {
[Parameter(Mandatory = $true)]
[String] $RolesDirectory,

[Parameter(Mandatory = $true)]
[string[]] $RoleNames,

[Parameter(Mandatory = $true)]
[String] $ManagementGroupId
)
Expand All @@ -29,13 +32,15 @@ function Set-Roles {
assignableMgId = $ManagementGroupId
}

foreach ($roleDefinition in Get-ChildItem -Path $RolesDirectory) {
Write-Output "Deploying $($roleDefinition.FullName)"
foreach ($RoleName in $RoleNames) {
$RoleDefinitionFilePath = "$RolesDirectory/$RoleName.bicep"

Write-Output "Deploying $RoleName ($RoleDefinitionFilePath)"

New-AzManagementGroupDeployment `
-ManagementGroupId $ManagementGroupId `
-Location $Context.DeploymentRegion `
-TemplateFile $roleDefinition.FullName `
-TemplateFile $RoleDefinitionFilePath `
-TemplateParameterObject $DeploymentParameters
}
}
2 changes: 2 additions & 0 deletions scripts/deployments/RunWorkflows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Param(
# What to deploy
[switch]$DeployManagementGroups,
[switch]$DeployRoles,
[string[]]$RoleNames=@('la-vminsights-readonly', 'lz-appowner', 'lz-netops', 'lz-secops', 'lz-subowner'),
[switch]$DeployLogging,
[switch]$DeployCustomPolicy,
[switch]$DeployBuiltinPolicy,
Expand Down Expand Up @@ -192,6 +193,7 @@ if ($DeployRoles) {
Set-Roles `
-Context $Context `
-RolesDirectory $Context.RolesDirectory `
-RoleNames $RoleNames `
-ManagementGroupId $Context.TopLevelManagementGroupId
}

Expand Down