Bylaw

Gallery › Azure Databricks › Azure Community Policy

Audit - Databricks should use customer-managed key for encrypting DBFS

Converted Policy Audit Disabled Mode All Version 1.0.0

Customer-managed key should be used to encrypt DBFS in Databricks service. The policy marks a resource Noncompliant if the prepareEncryption value is not set to true. The resource is also marked Noncompliant when the keySource value does not exist.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONazurepolicy.json · 52 lines
{
  "name": "06890ef8-c043-4a48-a791-58e95b6d5c11",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Audit - Databricks should use customer-managed key for encrypting DBFS",
    "description": "Customer-managed key should be used to encrypt DBFS in Databricks service. The policy marks a resource Noncompliant if the prepareEncryption value is not set to true. The resource is also marked Noncompliant when the keySource value does not exist.",
    "metadata": {
      "version": "1.0.0",
      "category": "Azure Databricks"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Databricks/workspaces"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Databricks/workspaces/parameters.prepareEncryption.value",
                "equals": false
              },
              {
                "field": "Microsoft.Databricks/workspaces/parameters.encryption.value.keySource",
                "exists": false
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw06890ef8-c043-4a48-a791-58e95b6d5c11.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '06890ef8-c043-4a48-a791-58e95b6d5c11' {

    Properties @{
        DisplayName = 'Audit - Databricks should use customer-managed key for encrypting DBFS'
        Description = 'Customer-managed key should be used to encrypt DBFS in Databricks service. The policy marks a resource Noncompliant if the prepareEncryption value is not set to true. The resource is also marked Noncompliant when the keySource value does not exist.'
        Version     = '1.0.0'
        Category    = 'Azure Databricks'
        Mode        = 'All'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.Databricks/workspaces' {

        Require 'parameters.prepareEncryption.value is not false' {
            Field parameters.prepareEncryption.value | Must -Not -Be $false -IfPresent
        }

        Require 'parameters.encryption.value.keySource exists' {
            Field parameters.encryption.value.keySource | Must -Exist
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Azure Databricks/audit-databricks-should-use-customer-managed-key-for-encrypting-dbfs/azurepolicy.json in Azure/Community-Policy, under the MIT licence.