@@ -26,6 +26,10 @@ inputs:
2626 deploymentType :
2727 description : ' The deployment type (managementGroup, subscription, resourceGroup)'
2828 required : true
29+ firstRunWhatIf :
30+ description : ' Run a what-if on the first run'
31+ required : false
32+ default : ' false'
2933 networkType :
3034 description : ' The network type filter'
3135 required : false
4650 $deploymentType = $env:DEPLOYMENT_TYPE
4751 $whatIfEnabled = $env:WHAT_IF_ENABLED -eq 'true'
4852
53+ # Check if we should skip what-if for first deployment
54+ $firstDeploymentString = $env:firstDeployment
55+ $firstDeployment = $true
56+ if($firstDeploymentString -eq "") {
57+ $firstDeployment = $false
58+ } else {
59+ $firstDeployment = [System.Convert]::ToBoolean($firstDeploymentString)
60+ }
61+
62+ $firstRunWhatIf = [System.Convert]::ToBoolean($env:FIRST_RUN_WHAT_IF)
63+
64+ if($whatIfEnabled -and $firstDeployment -and !$firstRunWhatIf) {
65+ Write-Warning "Skipping the What-If check as the deployment is dependent on resources that do not exist yet..."
66+ exit 0
67+ }
68+
4969 # Generate deployment name with timestamp (matching classic bicep pattern)
5070 $deploymentPrefix = "alz"
5171 $deploymentNameBase = $env:DISPLAY_NAME.Replace(" ", "-")
@@ -255,4 +275,5 @@ runs:
255275 RESOURCE_GROUP_NAME : $${{ inputs.resourceGroupName }}
256276 LOCATION : $${{ inputs.location }}
257277 DEPLOYMENT_TYPE : $${{ inputs.deploymentType }}
278+ FIRST_RUN_WHAT_IF : $${{ inputs.firstRunWhatIf }}
258279 WHAT_IF_ENABLED : $${{ inputs.whatIfEnabled }}
0 commit comments