Skip to content
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

What-if option does not show changes for modules #5073

Closed
samhughes91 opened this issue Nov 4, 2021 · 5 comments
Closed

What-if option does not show changes for modules #5073

samhughes91 opened this issue Nov 4, 2021 · 5 comments

Comments

@samhughes91
Copy link

samhughes91 commented Nov 4, 2021

Bicep version
Bicep CLI version 0.4.1008 (223b8d2)

Describe the bug
Hey guys,

After about a year of running into statefile issues with Terraform. I'm now in the process of converting our code into Bicep. I have a number of template bicep files to use as modules in my main bicep files. The template files are created at resourceGroup-level, when I run az deployment group --what-if the output shows what is to be changed as expected. However, when I use the same file as a module and call it from my main bicep file (targetScope = resourceGroup) withaz deployment group --what-if. The output shows none of the changes incurred by the module. After confirming and checking I can see that the changes have actually been deployed as shown in the template validation.

I'm finding it hard to understand why the changes inflicted by modules do not show in the what-if analysis. This seems to be quite a flaw when comparing it to the Terraform plan option for validation. Can anybody advise me on this matter?

To Reproduce
Steps to reproduce the behavior:

  1. Bicep template file
// Parameters
param env string = 'tst'
param location string = 'westeurope'
param rsvSku string = 'Standard'

// Variables

// Resources
resource rsv 'Microsoft.RecoveryServices/vaults@2021-08-01' = {
  name: 'rsv-dsp-${env}-001'
  location: location
  sku: {
    name: rsvSku
  }
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
  }
}
  1. run az deployment group create -g rg-test-bicep -f rsv-template.bicep --what-if

  2. Output shows RSV will be created:
    image

  3. Run the same code from a module:


// Parameters
param env string

module globalVars '../0-global-vars.bicep' = {
  scope: resourceGroup('XXXXXXXXXXX')
  name: 'globalVars'
}

module rsv '../templates/template-DELETE.bicep' = {
  scope: resourceGroup('XXXXXXXXXXX')
  name: 'rsv'
  params: {
    env: env
    location: globalVars.outputs.location
    rsvSku: 'Standard'
  }
}
  1. Run az deployment group create -g XXXXXXXXXXX --what-if -f main/main-DELETE.bicep -p env=tst

  2. Output
    image

  3. After confirming the changes I see the resource from the module was created even though it was not mentioned in the sub-level what-if command.

Additional context
I would expect to see the changes from the module in a deployment. Unfortunately I don't see anything. This makes the what-if kind of useless for me. Or am I misunderstanding something?

@ghost ghost added the Needs: Triage 🔍 label Nov 4, 2021
@samhughes91 samhughes91 changed the title what-if on sub-level deployments does not show changes at group-level What-if option does not show changes for modules Nov 4, 2021
@samhughes91
Copy link
Author

I just found this issue: #Azure/arm-template-whatif#157

@alex-frankel
Copy link
Collaborator

Yep, that's the one. We are getting close to fixing that bug, so hopefully will have good updates to share relatively soon.

Closing here for now.

@ryansh
Copy link

ryansh commented Feb 24, 2022

having the same issue!

@ehsan1503
Copy link

was this bug fixed ?

@alex-frankel
Copy link
Collaborator

Latest updates are here: Azure/arm-template-whatif#157 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants