-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed dependency ordering for cross scope deployments #2850
- Loading branch information
1 parent
7639775
commit cbe5b9b
Showing
8 changed files
with
295 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
// Test case for https://github.com/Azure/PSRule.Rules.Azure/issues/2850 | ||
|
||
// Handle from subscription scope. | ||
targetScope = 'subscription' | ||
|
||
param location string = deployment().location | ||
|
||
module site './Tests.Bicep.38.site.bicep' = { | ||
name: 'site' | ||
scope: resourceGroup('rg2') | ||
params: { | ||
name: 'app' | ||
location: location | ||
identityId: identity.outputs.id | ||
} | ||
} | ||
|
||
module identity './Tests.Bicep.38.child.bicep' = { | ||
name: 'mi' | ||
scope: resourceGroup('rg1') | ||
params: { | ||
name: 'mi' | ||
location: location | ||
} | ||
} |
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,12 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
param name string | ||
param location string = resourceGroup().location | ||
|
||
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = { | ||
name: name | ||
location: location | ||
} | ||
|
||
output id string = identity.id |
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,137 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"metadata": { | ||
"_generator": { | ||
"name": "bicep", | ||
"version": "0.26.170.59819", | ||
"templateHash": "17875932582636530478" | ||
} | ||
}, | ||
"parameters": { | ||
"location": { | ||
"type": "string", | ||
"defaultValue": "[deployment().location]" | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Resources/deployments", | ||
"apiVersion": "2022-09-01", | ||
"name": "site", | ||
"resourceGroup": "rg2", | ||
"properties": { | ||
"expressionEvaluationOptions": { | ||
"scope": "inner" | ||
}, | ||
"mode": "Incremental", | ||
"parameters": { | ||
"name": { | ||
"value": "app" | ||
}, | ||
"location": { | ||
"value": "[parameters('location')]" | ||
}, | ||
"identityId": { | ||
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'rg1'), 'Microsoft.Resources/deployments', 'mi'), '2022-09-01').outputs.id.value]" | ||
} | ||
}, | ||
"template": { | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"metadata": { | ||
"_generator": { | ||
"name": "bicep", | ||
"version": "0.26.170.59819", | ||
"templateHash": "9869420960933296536" | ||
} | ||
}, | ||
"parameters": { | ||
"location": { | ||
"type": "string", | ||
"defaultValue": "[resourceGroup().location]" | ||
}, | ||
"identityId": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"type": "string" | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Web/sites", | ||
"apiVersion": "2023-01-01", | ||
"name": "[parameters('name')]", | ||
"location": "[parameters('location')]", | ||
"identity": { | ||
"type": "UserAssigned", | ||
"userAssignedIdentities": { | ||
"[format('{0}', parameters('identityId'))]": {} | ||
} | ||
}, | ||
"properties": {} | ||
} | ||
] | ||
} | ||
}, | ||
"dependsOn": [ | ||
"[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'rg1'), 'Microsoft.Resources/deployments', 'mi')]" | ||
] | ||
}, | ||
{ | ||
"type": "Microsoft.Resources/deployments", | ||
"apiVersion": "2022-09-01", | ||
"name": "mi", | ||
"resourceGroup": "rg1", | ||
"properties": { | ||
"expressionEvaluationOptions": { | ||
"scope": "inner" | ||
}, | ||
"mode": "Incremental", | ||
"parameters": { | ||
"name": { | ||
"value": "mi" | ||
}, | ||
"location": { | ||
"value": "[parameters('location')]" | ||
} | ||
}, | ||
"template": { | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"metadata": { | ||
"_generator": { | ||
"name": "bicep", | ||
"version": "0.26.170.59819", | ||
"templateHash": "15990157618564203975" | ||
} | ||
}, | ||
"parameters": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"location": { | ||
"type": "string", | ||
"defaultValue": "[resourceGroup().location]" | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.ManagedIdentity/userAssignedIdentities", | ||
"apiVersion": "2023-01-31", | ||
"name": "[parameters('name')]", | ||
"location": "[parameters('location')]" | ||
} | ||
], | ||
"outputs": { | ||
"id": { | ||
"type": "string", | ||
"value": "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('name'))]" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
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,18 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
param location string = resourceGroup().location | ||
param identityId string | ||
param name string | ||
|
||
resource app 'Microsoft.Web/sites@2023-01-01' = { | ||
name: name | ||
location: location | ||
identity: { | ||
type: 'UserAssigned' | ||
userAssignedIdentities: { | ||
'${identityId}': {} | ||
} | ||
} | ||
properties: {} | ||
} |