Common Variables with parameters #17237
jachin84
started this conversation in
Authoring Help
Replies: 1 comment 1 reply
-
It sounds like user-defined functions may be a good fit for what you're trying to accomplish: //shared.bicep
type IdentityRoleAssignment = {
resourceName: string
resourceType: string
description: string
roleDefinitionGuid: string
}
type Identity = {
name: string
roleAssignments: IdentityRoleAssignment[]
}
type Config = {
identities: Identity[]
}
@export()
func getConfig(envCode string) Config => {
identities:[
{
name: '${envCode}-identity-frontend'
roleAssignments: [
{
resourceName: 'kv-${envCode}-a-good-name'
resourceType: 'Microsoft.KeyVault/vaults'
description: 'Grant ${envCode}-identity-frontend Key Vault Secrets User'
roleDefinitionGuid: '4633458b-17de-408a-b874-0445c86b69e6'
}
{
resourceName: 'st-${envCode}-a-good-name'
resourceType: 'Microsoft.Storage/storageAccounts'
description: 'Grant ${envCode}-identity-frontend Storage Blob Data Operator'
roleDefinitionGuid: 'b4ebbfbe-c18c-5c95-8387-1334df48050c'
}
]
}
]
}
//main.bicep
param envCode string = 'D'
import { getConfig } from './vars.bicep'
var config = getConfig(envCode)
//Deploy resources, etc.
output identityConfig array = config.identities |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
On a regular basis I find myself wanting to do something like this:
Is there any way to parameterize variables like this or something similar.
I am trying to avoid this scenario where I have huge parameter files that only differ by a single letter each line.

Beta Was this translation helpful? Give feedback.
All reactions