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

Failed to expand nest deployment with runtime shallow parameter #2004

Closed
BernieWhite opened this issue Jan 26, 2023 · 0 comments · Fixed by #2006
Closed

Failed to expand nest deployment with runtime shallow parameter #2004

BernieWhite opened this issue Jan 26, 2023 · 0 comments · Fixed by #2006
Assignees
Labels
bug Something isn't working feature: bicep-language Issues relating to Bicep language support.
Milestone

Comments

@BernieWhite
Copy link
Collaborator

Reported by @Gordonby in microsoft/PSRule#1418

Description of the issue

I am encountering an issue running PSRule.Rules.Azure using PSRule 2.6 and 2.7 in my GitHub workflow.

Unable to expand resources because the source file '/home/runner/work/AKS-Construction/AKS-Construction/bicep/main.bicep' was not valid. Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken.

To Reproduce

Use the param file https://github.com/Azure/AKS-Construction/blob/main/.github/workflows_dep/AksDeploy-ByoVnet.parameters.json

Module in use and version:

  • Module: PSRule
  • Version: 2.7.0

Additional context

Workflow result : https://github.com/Azure/AKS-Construction/actions/runs/4009804697
Workflow file: https://github.com/Azure/AKS-Construction/blob/main/.github/workflows/ByoVnetCI.yml#L86
PSRule settings: https://github.com/Azure/AKS-Construction/blob/main/ps-rule.yaml

This issue is occurring for shallow parameters of nested templates that reference runtime properties. For example user_identity_principalId:

{
      "condition": "[and(not(empty(parameters('byoAKSSubnetId'))), variables('createAksUai'))]",
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2020-10-01",
      "name": "addAksNetContributor",
      "resourceGroup": "[variables('existingAksVnetRG')]",
      "properties": {
        "expressionEvaluationOptions": {
          "scope": "inner"
        },
        "mode": "Incremental",
        "parameters": {
          "byoAKSSubnetId": {
            "value": "[parameters('byoAKSSubnetId')]"
          },
          "user_identity_principalId": "[if(variables('createAksUai'), createObject('value', reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('id-aks-{0}', parameters('resourceName'))), '2018-11-30').principalId), createObject('value', ''))]",
          "rbacAssignmentScope": {
            "value": "[variables('uaiNetworkScopeRbac')]"
          }
        },
        "template": {
          
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('id-aks-{0}', parameters('resourceName')))]"
      ]
    }
@BernieWhite BernieWhite added bug Something isn't working feature: bicep-language Issues relating to Bicep language support. labels Jan 26, 2023
@BernieWhite BernieWhite added this to the v1.24.0 milestone Jan 26, 2023
@BernieWhite BernieWhite self-assigned this Jan 26, 2023
BernieWhite added a commit to BernieWhite/PSRule.Rules.Azure that referenced this issue Jan 27, 2023
BernieWhite added a commit that referenced this issue Jan 27, 2023
* Fixes expand of runtime shallow param #2004

* Fix exception class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature: bicep-language Issues relating to Bicep language support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant