Bylaw

Gallery › Data Box › Azure built-in policies

Azure Data Box jobs should use a customer-managed key to encrypt the device unlock password

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Use a customer-managed key to control the encryption of the device unlock password for Azure Data Box. Customer-managed keys also help manage access to the device unlock password by the Data Box service in order to prepare the device and copy data in an automated manner. The data on the device itself is already encrypted at rest with Advanced Encryption Standard 256-bit encryption, and the device unlock password is encrypted by default with a Microsoft managed key.

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

Azure Policy JSONCMK_Audit.json · 70 lines
{
  "properties": {
    "displayName": "Azure Data Box jobs should use a customer-managed key to encrypt the device unlock password",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Use a customer-managed key to control the encryption of the device unlock password for Azure Data Box. Customer-managed keys also help manage access to the device unlock password by the Data Box service in order to prepare the device and copy data in an automated manner. The data on the device itself is already encrypted at rest with Advanced Encryption Standard 256-bit encryption, and the device unlock password is encrypted by default with a Microsoft managed key.",
    "metadata": {
      "version": "1.0.0",
      "category": "Data Box"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "The desired effect of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      },
      "supportedSKUs": {
        "type": "Array",
        "metadata": {
          "displayName": "Supported SKUs",
          "description": "The list of SKUs that support customer-managed key encryption key"
        },
        "allowedValues": [
          "DataBox",
          "DataBoxHeavy"
        ],
        "defaultValue": [
          "DataBox",
          "DataBoxHeavy"
        ]
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.DataBox/jobs"
          },
          {
            "field": "Microsoft.Databox/jobs/sku.name",
            "in": "[parameters('supportedSKUs')]"
          },
          {
            "field": "Microsoft.DataBox/jobs/details.keyEncryptionKey.kekType",
            "notEquals": "CustomerManaged"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/86efb160-8de7-451d-bc08-5d475b0aadae",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "86efb160-8de7-451d-bc08-5d475b0aadae"
}
Bylaw86efb160-8de7-451d-bc08-5d475b0aadae.bylaw.ps1 · 39 lines
# Converted from CMK_Audit.json by ConvertTo-Bylaw.
Policy '86efb160-8de7-451d-bc08-5d475b0aadae' {

    Properties @{
        DisplayName   = 'Azure Data Box jobs should use a customer-managed key to encrypt the device unlock password'
        Description   = 'Use a customer-managed key to control the encryption of the device unlock password for Azure Data Box. Customer-managed keys also help manage access to the device unlock password by the Data Box service in order to prepare the device and copy data in an automated manner. The data on the device itself is already encrypted at rest with Advanced Encryption Standard 256-bit encryption, and the device unlock password is encrypted by default with a Microsoft managed key.'
        Version       = '1.0.0'
        Category      = 'Data Box'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The desired effect of the policy'
    }
    Parameter SupportedSKUs @{
        Type          = 'Array'
        AllowedValues = @('DataBox', 'DataBoxHeavy')
        Default       = @('DataBox', 'DataBoxHeavy')
        DisplayName   = 'Supported SKUs'
        Description   = 'The list of SKUs that support customer-managed key encryption key'
    }

    Resource 'Microsoft.DataBox/jobs' {

        When {
            Field sku.name | Must -BeIn (Param SupportedSKUs)
        }

        Require 'details.keyEncryptionKey.kekType is CustomerManaged' {
            Field details.keyEncryptionKey.kekType | Must -Be 'CustomerManaged'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Data Box/CMK_Audit.json in Azure/azure-policy, under the MIT licence.