Skip to content

Commit 0bf2ccf

Browse files
Merge pull request #484 from microsoft/dev
fix: Merging the changes from dev to main
2 parents 89b254a + 27e05ef commit 0bf2ccf

File tree

3 files changed

+542
-289
lines changed

3 files changed

+542
-289
lines changed

Deployment/resourcedeployment.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,38 @@ try {
579579

580580
# 2.Connect to AKS cluster
581581
try {
582+
Write-Host "Checking if user already has AKS Cluster Admin role..." -ForegroundColor Cyan
583+
# -----------------------------------------
584+
# Check and assign AKS RBAC Cluster Admin role
585+
# -----------------------------------------
586+
587+
$subscriptionId = (az account show --query id -o tsv)
588+
$resourceGroup = $deploymentResult.ResourceGroupName
589+
$aksName = $deploymentResult.AksName
590+
591+
# Get current signed-in user
592+
$currentUser = az ad signed-in-user show --query id -o tsv
593+
594+
# Get AKS resource ID
595+
$aksResourceId = az aks show --resource-group $resourceGroup --name $aksName --subscription $subscriptionId --query id -o tsv
596+
597+
# Check if role already assigned
598+
$roleCheck = az role assignment list `
599+
--assignee $currentUser `
600+
--role "Azure Kubernetes Service RBAC Cluster Admin" `
601+
--scope $aksResourceId `
602+
--query "[].id" -o tsv
603+
604+
if (-not $roleCheck) {
605+
Write-Host "Assigning 'Azure Kubernetes Service RBAC Cluster Admin' role to current user..."
606+
az role assignment create `
607+
--assignee $currentUser `
608+
--role "Azure Kubernetes Service RBAC Cluster Admin" `
609+
--scope $aksResourceId | Out-Null
610+
Write-Host "Role assignment complete."
611+
} else {
612+
Write-Host "User already has 'Azure Kubernetes Service RBAC Cluster Admin' role."
613+
}
582614
Write-Host "Connecting to AKS cluster..." -ForegroundColor Cyan
583615
az aks get-credentials --resource-group $deploymentResult.ResourceGroupName --name $deploymentResult.AksName --overwrite-existing
584616
Write-Host "Connected to AKS cluster." -ForegroundColor Green

infra/main.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
111111
name: 'default'
112112
properties: {
113113
tags: {
114+
...resourceGroup().tags
114115
...tags
115116
TemplateName: 'DKM'
116117
Type: enablePrivateNetworking ? 'WAF' : 'Non-WAF'

0 commit comments

Comments
 (0)