Skip to content

Commit

Permalink
ci: fix role assignements
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Jun 28, 2024
1 parent d91297c commit 0380748
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
24 changes: 21 additions & 3 deletions infra/app/llama-index-nextjs.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ param containerRegistryName string
param containerAppsEnvironmentName string
param applicationInsightsName string
param exists bool

@description('Whether the deployment is running on GitHub Actions')
param runningOnGh string = ''

@secure()
param appDefinition object

Expand Down Expand Up @@ -42,17 +46,31 @@ resource acrPullRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
scope: containerRegistry
name: guid(subscription().id, resourceGroup().id, identity.id, 'acrPullRole')
properties: {
roleDefinitionId: subscriptionResourceId(
'Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')
roleDefinitionId: '7f951dda-4ed3-4680-a7ca-43fe172d538d'
principalType: 'ServicePrincipal'
principalId: identity.properties.principalId
}
}


// Roles

// User roles
module openAiRoleUser '../shared/role.bicep' = if (empty(runningOnGh)) {
scope: resourceGroup()
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiUserRole')
params: {
principalId: app.identity.principalId
// Cognitive Services OpenAI User
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
principalType: 'User'
}
}

// System roles
module openAiRole '../shared/role.bicep' = {
scope: resourceGroup()
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiUserRole')
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiServicePrincipalRole')
params: {
principalId: app.identity.principalId
// Cognitive Services OpenAI User
Expand Down
22 changes: 8 additions & 14 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ param environmentName string
@description('Primary location for all resources')
param location string

@description('Whether the deployment is running on GitHub Actions')
param runningOnGh string = ''

param llamaIndexNextjsExists bool
@secure()
param llamaIndexNextjsDefinition object
Expand Down Expand Up @@ -154,26 +157,13 @@ module openAi './shared/cognitiveservices.bicep' = if (empty(openAiUrl)) {
}
}

// Roles

// User roles
module openAiRoleUser './shared/role.bicep' = {
scope: rg
name: 'openai-role-user'
params: {
principalId: principalId
// Cognitive Services OpenAI User
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
principalType: 'User'
}
}

module llamaIndexNextjs './app/llama-index-nextjs.bicep' = {
name: 'llama-index-nextjs'
params: {
name: '${abbrs.appContainerApps}llama-index-${resourceToken}'
location: location
tags: tags
runningOnGh: runningOnGh
identityName: '${abbrs.managedIdentityUserAssignedIdentities}llama-index-${resourceToken}'
applicationInsightsName: monitoring.outputs.applicationInsightsName
containerAppsEnvironmentName: appsEnv.outputs.name
Expand Down Expand Up @@ -237,6 +227,10 @@ module llamaIndexNextjs './app/llama-index-nextjs.bicep' = {
name: 'SYSTEM_PROMPT'
value: llamaIndexConfig.system_prompt
}
{
name: 'OPENAI_API_TYPE'
value: 'AzureOpenAI'
}
]
})
}
Expand Down
4 changes: 2 additions & 2 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"openAiApiVersion": {
"value": "${AZURE_OPENAI_API_VERSION=2024-02-15-preview}"
},
"isContinuousDeployment": {
"value": "${CI=false}"
"runningOnGh": {
"value": "${GITHUB_ACTIONS}"
},
"azureDeploymentName": {
"value": "${AZURE_DEPLOYMENT_NAME=gpt-35-turbo}"
Expand Down

0 comments on commit 0380748

Please sign in to comment.