Skip to content

Commit

Permalink
feat(tools): add iam module to assign reader role to service principal
Browse files Browse the repository at this point in the history
  • Loading branch information
Harjot1Singh committed Oct 22, 2023
1 parent 2d96da8 commit 1dceb5f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tools/iam.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { authorization } from '@pulumi/azure-native'

import identity from '../shared/identity'

type Options = {
identity: Awaited<ReturnType<typeof identity>>,
}

const iamModule = async ( {
identity,
}: Options ) => {
new authorization.RoleAssignment( 'azure-sp-role-assignment', {
principalId: identity.servicePrincipal.id,
principalType: authorization.PrincipalType.ServicePrincipal,
roleDefinitionId: '/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7',
scope: identity.resourceGroup.id,
} )
}

export default iamModule
2 changes: 2 additions & 0 deletions tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import azureModule from '../shared/azure'
import identityModule from '../shared/identity'
import azureSecretsModule from './azure-secrets'
import codeSigningSecretsModule from './code-signing-secrets'
import iamModule from './iam'
import keyVaultModule from './key-vault'

const stack = async () => {
const azure = await azureModule()

const identity = await identityModule()
await iamModule( { identity } )

const keyVault = await keyVaultModule( { azure, identity } )

Expand Down

0 comments on commit 1dceb5f

Please sign in to comment.