Skip to content

Commit

Permalink
Fixed a null index by adding a condition
Browse files Browse the repository at this point in the history
  • Loading branch information
jamasten committed Sep 12, 2024
1 parent 90e30af commit e9bc47b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "17585166685464872752"
"templateHash": "13272185734120658047"
}
},
"parameters": {
Expand Down Expand Up @@ -132,41 +132,7 @@
}
},
"variables": {
"Roles": [
{
"resourceGroup": "[split(parameters('existingVirtualNetworkResourceId'), '/')[4]]",
"name": "Virtual Network Join",
"description": "Allow resources to join a subnet",
"permissions": [
{
"actions": [
"Microsoft.Network/virtualNetworks/read",
"Microsoft.Network/virtualNetworks/subnets/read",
"Microsoft.Network/virtualNetworks/subnets/join/action",
"Microsoft.Network/virtualNetworks/subnets/write"
]
}
]
},
{
"resourceGroup": "[parameters('resourceGroupName')]",
"name": "Image Template Contributor",
"description": "Allow the creation and management of images",
"permissions": [
{
"actions": [
"Microsoft.Compute/galleries/read",
"Microsoft.Compute/galleries/images/read",
"Microsoft.Compute/galleries/images/versions/read",
"Microsoft.Compute/galleries/images/versions/write",
"Microsoft.Compute/images/read",
"Microsoft.Compute/images/write",
"Microsoft.Compute/images/delete"
]
}
]
}
]
"Roles": "[union(if(empty(parameters('existingVirtualNetworkResourceId')), createArray(), createArray(createObject('resourceGroup', split(parameters('existingVirtualNetworkResourceId'), '/')[4], 'name', 'Virtual Network Join', 'description', 'Allow resources to join a subnet', 'permissions', createArray(createObject('actions', createArray('Microsoft.Network/virtualNetworks/read', 'Microsoft.Network/virtualNetworks/subnets/read', 'Microsoft.Network/virtualNetworks/subnets/join/action', 'Microsoft.Network/virtualNetworks/subnets/write')))))), createArray(createObject('resourceGroup', parameters('resourceGroupName'), 'name', 'Image Template Contributor', 'description', 'Allow the creation and management of images', 'permissions', createArray(createObject('actions', createArray('Microsoft.Compute/galleries/read', 'Microsoft.Compute/galleries/images/read', 'Microsoft.Compute/galleries/images/versions/read', 'Microsoft.Compute/galleries/images/versions/write', 'Microsoft.Compute/images/read', 'Microsoft.Compute/images/write', 'Microsoft.Compute/images/delete'))))))]"
},
"resources": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ param userAssignedIdentityName string
// Variables //
// =========== //

var Roles = [
var Roles = union(empty(existingVirtualNetworkResourceId) ? [] : [
{
resourceGroup: split(existingVirtualNetworkResourceId, '/')[4]
name: 'Virtual Network Join'
Expand All @@ -86,6 +86,7 @@ var Roles = [
}
]
}
], [
{
resourceGroup: resourceGroupName
name: 'Image Template Contributor'
Expand All @@ -104,7 +105,7 @@ var Roles = [
}
]
}
]
])


// =========== //
Expand Down

0 comments on commit e9bc47b

Please sign in to comment.