-
Notifications
You must be signed in to change notification settings - Fork 757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot create a child resource for a parent with an explicit resource group scope #5660
Comments
Except for a few exceptions, the scope for a resource will always be the scope of the current bicep file. If you need to change the scope of where a resource is deployed, you need to declare a module which deploys to a different scope like so: module deploySql 'deploySql.bicep' = {
scope: resourceGroup('some-rg')
...
} Then in the |
Thanks for the answer, using modules is a good workaround. However, don't you think that:
At the very least, maybe the error messages could be improved. BCP165 seems to suggest to change the Bicep code so that BCP165 is issued and the other way around. |
I agree the error message is misleading here -- the root cause is BCP164. The child resource does automatically inherit the parent resource scope. The issue is trying the set the @anthony-c-martin / @shenglol / @majastrz -- is there a way that we could have thrown BCP164 instead of BCP165 in this scenario? |
I had a go at rewording the errors - see the diff here. Do these seem any clearer? |
@alex-frankel Wondering why it's disallowed like this |
It is just not technically possible today. It would be nice to enable this at some point. |
Bicep version
Bicep VS Code extension 0.4.1124
Describe the bug
I want to declare a child resource using the
parent
syntax, where the parent resource has a specific resource group as its scope. (I'm forced to use theparent
syntax because I want to use a loop.)Cannot deploy a resource with ancestor under a different scope. Resource "azureSqlServers" has the "scope" property set.bicep(BCP165)
The "scope" property is unsupported for a resource with a parent resource. This resource has "azureSqlServer" declared as its parent.bicep(BCP164)
To Reproduce
Simple repro, with the loop removed:
Additional context
This is probably related to #2990, but it's not about tenant-scoped resources.
Should this have been considered as a valid scenario in #4394?
The text was updated successfully, but these errors were encountered: