Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Azure NetApp Files accounts should use customer-managed keys to encrypt data at rest

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0-preview Preview

Use customer-managed keys to manage encryption at rest for Azure NetApp Files accounts. Customer-managed keys enable data to be encrypted with an Azure Key Vault key created and owned by you, giving you control over the key lifecycle, including rotation and management.

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

Azure Policy JSONNetAppAccountCMK_Audit.json · 59 lines
{
  "properties": {
    "displayName": "[Preview]: Azure NetApp Files accounts should use customer-managed keys to encrypt data at rest",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Use customer-managed keys to manage encryption at rest for Azure NetApp Files accounts. Customer-managed keys enable data to be encrypted with an Azure Key Vault key created and owned by you, giving you control over the key lifecycle, including rotation and management.",
    "metadata": {
      "version": "1.0.0-preview",
      "preview": true,
      "category": "Sovereignty"
    },
    "version": "1.0.0-preview",
    "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.NetApp/netAppAccounts"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.NetApp/netAppAccounts/encryption.keyVaultProperties.keyVaultUri",
                "exists": false
              },
              {
                "field": "Microsoft.NetApp/netAppAccounts/encryption.keyVaultProperties.keyVaultUri",
                "equals": ""
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/8855a114-45dd-4bb9-9953-4cc527764c90",
  "name": "8855a114-45dd-4bb9-9953-4cc527764c90"
}
Bylaw8855a114-45dd-4bb9-9953-4cc527764c90.bylaw.ps1 · 33 lines
# Converted from NetAppAccountCMK_Audit.json by ConvertTo-Bylaw.
Policy '8855a114-45dd-4bb9-9953-4cc527764c90' {

    Properties @{
        DisplayName   = '[Preview]: Azure NetApp Files accounts should use customer-managed keys to encrypt data at rest'
        Description   = 'Use customer-managed keys to manage encryption at rest for Azure NetApp Files accounts. Customer-managed keys enable data to be encrypted with an Azure Key Vault key created and owned by you, giving you control over the key lifecycle, including rotation and management.'
        Version       = '1.0.0-preview'
        Preview       = $true
        Category      = 'Sovereignty'
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.NetApp/netAppAccounts' {

        Require 'encryption.keyVaultProperties.keyVaultUri exists' {
            Field encryption.keyVaultProperties.keyVaultUri | Must -Exist
        }

        Require 'encryption.keyVaultProperties.keyVaultUri is not' {
            Field encryption.keyVaultProperties.keyVaultUri | Must -Not -Be '' -IfPresent
        }
    }

    Effect (Param Effect)
}

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