forked from Azure/deployment-environments
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use shared aks project name and environment name instead of identity …
…profile object id
- Loading branch information
Showing
4 changed files
with
132 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
param aksName string | ||
resource aks 'Microsoft.ContainerService/managedClusters@2023-10-02-preview' existing = { | ||
name: aksName | ||
} | ||
output aksIdentityObjectId string = aks.properties.identityProfile.kubeletidentity.objectId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@description('app deployment name') | ||
param appDeployName string | ||
|
||
@description('Shared AKS resource group') | ||
param aksResourceGroupName string | ||
|
||
@description('Timestamp - utcNow can only be called as a default value of a parameter.') | ||
param timestamp string = utcNow() | ||
|
||
@description('The location to run the deployment script in') | ||
param location string = resourceGroup().location | ||
|
||
param identityName string | ||
|
||
var scriptToExecute = ''' | ||
$output = Get-AzResource -ResourceGroupName $Env:RESOURCEGROUP -ResourceType Microsoft.ContainerService/ManagedClusters | ||
Write-Output $output | ||
$DeploymentScriptOutputs = @{} | ||
$DeploymentScriptOutputs['text'] = $output.Name | ||
''' | ||
|
||
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = { | ||
name: identityName | ||
location: location | ||
} | ||
|
||
module roleAssignemnt './core/security/role.bicep' = { | ||
name: 'read-role-assignment-to-aks' | ||
scope: resourceGroup(aksResourceGroupName) | ||
params: { | ||
principalId: identity.properties.principalId | ||
roleDefinitionId: 'acdd72a7-3385-48ef-bd42-f606fba81ae7' | ||
} | ||
} | ||
|
||
resource script 'Microsoft.Resources/deploymentScripts@2020-10-01' = { | ||
kind: 'AzurePowerShell' | ||
name: '${appDeployName}-get-aks-script' | ||
location: location | ||
identity: { | ||
type: 'UserAssigned' | ||
userAssignedIdentities: { | ||
'${identity.id}' : {} | ||
} | ||
} | ||
properties: { | ||
forceUpdateTag: timestamp | ||
azPowerShellVersion: '7.2.0' | ||
retentionInterval: 'PT1H' | ||
scriptContent: scriptToExecute | ||
cleanupPreference: 'Always' | ||
environmentVariables: [ | ||
{ | ||
name: 'RESOURCEGROUP' | ||
value: aksResourceGroupName | ||
} | ||
] | ||
} | ||
} | ||
|
||
output clusterName string = empty(script.properties.outputs.text) ? '' : script.properties.outputs.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters