Bylaw

Gallery › Automation › Azure built-in policies

Azure Automation accounts should use customer-managed keys to encrypt data at rest

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Use customer-managed keys to manage the encryption at rest of your Azure Automation Accounts. By default, customer data is encrypted with service-managed keys, but customer-managed keys are commonly required to meet regulatory compliance standards. Customer-managed keys enable the data to be encrypted with an Azure Key Vault key created and owned by you. You have full control and responsibility for the key lifecycle, including rotation and management. Learn more at https://aka.ms/automation-cmk.

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

Azure Policy JSONAccount_CMK_Audit.json · 50 lines
{
  "properties": {
    "policyType": "BuiltIn",
    "displayName": "Azure Automation accounts should use customer-managed keys to encrypt data at rest",
    "description": "Use customer-managed keys to manage the encryption at rest of your Azure Automation Accounts. By default, customer data is encrypted with service-managed keys, but customer-managed keys are commonly required to meet regulatory compliance standards. Customer-managed keys enable the data to be encrypted with an Azure Key Vault key created and owned by you. You have full control and responsibility for the key lifecycle, including rotation and management. Learn more at https://aka.ms/automation-cmk.",
    "metadata": {
      "version": "1.0.0",
      "category": "Automation"
    },
    "version": "1.0.0",
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "'Audit' allows a non-compliant resource to be created or updated, but flags it as non-compliant. 'Deny' blocks the non-compliant resource creation or update. 'Disabled' turns off the policy."
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Automation/automationAccounts"
          },
          {
            "field": "Microsoft.Automation/automationAccounts/encryption.keySource",
            "notEquals": "Microsoft.Keyvault"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/56a5ee18-2ae6-4810-86f7-18e39ce5629b",
  "name": "56a5ee18-2ae6-4810-86f7-18e39ce5629b"
}
Bylaw56a5ee18-2ae6-4810-86f7-18e39ce5629b.bylaw.ps1 · 28 lines
# Converted from Account_CMK_Audit.json by ConvertTo-Bylaw.
Policy '56a5ee18-2ae6-4810-86f7-18e39ce5629b' {

    Properties @{
        DisplayName   = 'Azure Automation accounts should use customer-managed keys to encrypt data at rest'
        Description   = 'Use customer-managed keys to manage the encryption at rest of your Azure Automation Accounts. By default, customer data is encrypted with service-managed keys, but customer-managed keys are commonly required to meet regulatory compliance standards. Customer-managed keys enable the data to be encrypted with an Azure Key Vault key created and owned by you. You have full control and responsibility for the key lifecycle, including rotation and management. Learn more at https://aka.ms/automation-cmk.'
        Version       = '1.0.0'
        Category      = 'Automation'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = '''Audit'' allows a non-compliant resource to be created or updated, but flags it as non-compliant. ''Deny'' blocks the non-compliant resource creation or update. ''Disabled'' turns off the policy.'
    }

    Resource 'Microsoft.Automation/automationAccounts' {

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

    Effect (Param Effect)
}

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