I am pulling policies from an azure keyvault
policies=$(az keyvault show --name $KeyVaultName --resource-group $ResourceGroupName --query "properties.accessPolicies")
Which returns some data like
[
{
"applicationId": null,
"objectId": "0123b8ac-57a6-1234-9816-ff5swa4b6d0b",
"permissions": {
"certificates": [
"Get",
"Release"
],
"keys": null
"secrets": null,
"storage": null
},
"tenantId": "abc-123"
},
{
"applicationId": null,
"objectId": "f4340076-d4ea-1234-a719-c75dfsat4d17",
"permissions": {
"certificates": null,
"keys": [
"Get",
"Release"
],
"secrets": null,
"storage": null
},
"tenantId": "abc-123"
}
]
Somehow I need to filter out the null permission objects, either by completely removing them or by replacing them with empty arrays. There could be any combination of policies. Is it possible to filter these out? I've been trying variations of jmespath and jq for hours and getting nowhere.