-
Notifications
You must be signed in to change notification settings - Fork 753
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
Reference resource group that is created via a module #4992
Comments
The recommendation is to create the "raw" RG resource in main.bicep like so: param resourceGroupName string = 'bb-poc'
var location = deployment().location
var resourceGroupNameWithSuffix= 'rg-${resourceGroupName}'
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: resourceGroupNameWithSuffix
location: location
}
module appServicePlanDeployment '../resources/appServicePlan.bicep' = {
name: 'appserviceplandeploy'
scope: rg
params:{
appServicePlanName: 'testing'
}
} Is it a hard requirement to create the resource group in a module? |
Yeah that recommendation is what I mentioned that I know it works, but isn't what I want. |
Ah, sorry I missed that statement. Unfortunately, this is not possible today due to some runtime limitations. A module output is a runtime reference, but we need to be able to calculate special values like In theory, we could do deeper constant folding (#444) to enable this for certain scenarios where no runtime properties are used (which this example would qualify as since no parameters are used). |
@alex-frankel any chance you have an update on this on? |
No updates. I think we should revisit this after #2246 is implemented. I assume that functionality will be required to fix the properly. |
I've come here. Same problem. We create rsgs elsewhere. Tried creating and asserting existing in the same module and it doesn't work. Back to messy 'depends on' for me |
I have run into this issue today. I moved the resource group out of the module like suggested and then realised I couldn't also deploy a subscription in the same bicep file as this requires the scope to be the tenant which leads to this error on the resource group resource:
Obviously I can't put the resource group in a module because of the above issue. I am going to have to look into running separate scripts in a pipeline to get this working for me |
I had the same issue today |
Created this issue based on #1454.
What Im trying to do is within the same deployment, create a resource groupby using a module and then create other resources. When doing so, currently I cant reference the resourcegroup outputs in the scope, since this is disabled. My question is, how can it work in this setup?
I am specifically asking how it can work with a module resource group, since I know that creating the resource resourcegroup in the main template itself will work. For my current usecase, I want to use a precreated module of a resource group:
resourceGroup.bicep :
main.bicep
Current error on the line
scope: resourceGroup(rg.outputs.resourceGroupName)
:
This expression is being used in an assignment to the "scope" property of the "module" type, which requires a value that can be calculated at the start of the deployment. Properties of rg which can be calculated at the start include "name".b
The text was updated successfully, but these errors were encountered: