Bylaw

Gallery › Mission › Azure built-in policies

Storage accounts should use customer-managed key for encryption in Mission Platform products and services

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Secure your blob and file storage account with greater flexibility using customer-managed keys. When you specify a customer-managed key, that key is used to protect and control access to the key that encrypts your data. Using customer-managed keys provides additional capabilities to control rotation of the key encryption key or cryptographically erase data.

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

Azure Policy JSONStorageEncryptWithCMK_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Storage accounts should use customer-managed key for encryption in Mission Platform products and services",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Secure your blob and file storage account with greater flexibility using customer-managed keys. When you specify a customer-managed key, that key is used to protect and control access to the key that encrypts your data. Using customer-managed keys provides additional capabilities to control rotation of the key encryption key or cryptographically erase data.",
    "metadata": {
      "version": "1.0.0",
      "category": "Mission"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts"
          },
          {
            "field": "Microsoft.Storage/storageAccounts/encryption.keySource",
            "notEquals": "Microsoft.Keyvault"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/e089ecb6-8b98-4b7b-b26b-9bbee7385395",
  "name": "e089ecb6-8b98-4b7b-b26b-9bbee7385395"
}
Bylawe089ecb6-8b98-4b7b-b26b-9bbee7385395.bylaw.ps1 · 28 lines
# Converted from StorageEncryptWithCMK_Audit.json by ConvertTo-Bylaw.
Policy 'e089ecb6-8b98-4b7b-b26b-9bbee7385395' {

    Properties @{
        DisplayName   = 'Storage accounts should use customer-managed key for encryption in Mission Platform products and services'
        Description   = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Secure your blob and file storage account with greater flexibility using customer-managed keys. When you specify a customer-managed key, that key is used to protect and control access to the key that encrypts your data. Using customer-managed keys provides additional capabilities to control rotation of the key encryption key or cryptographically erase data.'
        Version       = '1.0.0'
        Category      = 'Mission'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Storage/storageAccounts' {

        Require 'encryption.keySource is Microsoft.Keyvault' {
            Field encryption.keySource | Must -Be 'Microsoft.Keyvault'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Mission/StorageEncryptWithCMK_Audit.json in Azure/azure-policy, under the MIT licence.