Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.21k stars 742 forks source link

Warning BCP036: The property "effect" expected a value of type "ParameterValuesValue" but the provided value is of type "string". #1340

Closed khowling closed 3 years ago

khowling commented 3 years ago

Bicep CLI version 0.2.212 (a19d66c04c)

Wondering how to make this build warning go away

resource aks_policies 'Microsoft.Authorization/policyAssignments@2019-09-01' = {
  name: 'aks_policy_assignment'
  location: location
  properties: {
    scope: aks.id
    policyDefinitionId: policySetPodSecBaseline
    parameters: {
      excludedNamespaces: '[  "kube-system",  "gatekeeper-system",  "azure-arc"]'
      effect: azurepolicy
    }
  }
}

Warning BCP036: The property "excludedNamespaces" expected a value of type "ParameterValuesValue" but the provided value is of type "'[ "kube-system", "gatekeeper-system", "azure-arc"]'". /home/kehowli/projects/quest/aks-deploy-arm/main.bicep(522,15) : Warning BCP036: The property "effect" expected a value of type "ParameterValuesValue" but the provided value is of type "string".

alex-frankel commented 3 years ago

You should be able to use the any() function like so:

resource aks_policies 'Microsoft.Authorization/policyAssignments@2019-09-01' = {
  name: 'aks_policy_assignment'
  location: location
  properties: {
    scope: aks.id
    policyDefinitionId: policySetPodSecBaseline
    parameters: {
      excludedNamespaces: any('[  "kube-system",  "gatekeeper-system",  "azure-arc"]')
      effect: any(azurepolicy)
    }
  }
}
alex-frankel commented 3 years ago

Though @anthony-c-martin, I'm curious about the warning. Is that an issue with the swagger definition?

anthony-c-martin commented 3 years ago

It seems like this resource type expects parameter values to be wrapped in an object with a value key. Modifying the original report, that would be:

resource aks_policies 'Microsoft.Authorization/policyAssignments@2019-09-01' = {
  name: 'aks_policy_assignment'
  location: location
  properties: {
    scope: aks.id
    policyDefinitionId: policySetPodSecBaseline
    parameters: {
      excludedNamespaces: {
        value: '[  "kube-system",  "gatekeeper-system",  "azure-arc"]'
      }
      effect: {
        value: azurepolicy
      }
    }
  }
}
khowling commented 3 years ago

Awesome, thankyou @anthony-c-martin , thats fixed it!