Azure / deployment-stacks

Contains Deployment Stacks CLI scripts and releases
MIT License
87 stars 6 forks source link

Deployment Stacks, unable to Add an existing resource (ie created outside of Bicep) into Deployment Stack #146

Closed lukemurraynz closed 6 months ago

lukemurraynz commented 6 months ago

Bicep version Bicep CLI version 0.24.24

Describe the bug Deployment Stacks, unable to Add an existing resource (ie created outside of Bicep) into Deployment Stack

To Reproduce

Bicep;

param stgnamme string = 'stfacc1337'

resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' existing = { name: stgnamme scope: resourceGroup('deploymentstacks-rg') }

-- Along with other resources, that are deployed from Bicep, that are in the Deployment Stack.

Using the following commands: Set-AzResourceGroupDeploymentStack -Name "MyRGStack" -ResourceGroupName "deploymentstacks-rg" -TemplateFile "main.bicep" -DenySettingsMode "DenyDelete"

lukemurraynz commented 6 months ago

I got it working, by Inserting the resource into Bicep, instead of using the Existing flag.

alex-frankel commented 6 months ago

Thanks Luke - FWIW, this is the expected behavior. existing is only a reference to a resource that you are intentionally not deploying in the stack, so we make sure not to add it to the list of managed resources.