Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Azure Managed Lustre file systems should use customer-managed keys for encryption

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

Use customer-managed keys to manage encryption at rest for Azure Managed Lustre file systems. Customer-managed keys enable data to be encrypted with Azure Key Vault keys that you own and manage.

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

Azure Policy JSONAmlFilesystem_CMKEnabled_Audit.json · 71 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Managed Lustre file systems should use customer-managed keys for encryption",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Use customer-managed keys to manage encryption at rest for Azure Managed Lustre file systems. Customer-managed keys enable data to be encrypted with Azure Key Vault keys that you own and manage.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Sovereignty",
      "preview": true
    },
    "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.StorageCache/amlFilesystems"
          },
          {
            "anyOf": [
              {
                "field": "identity.type",
                "notEquals": "UserAssigned"
              },
              {
                "field": "Microsoft.StorageCache/amlFilesystems/encryptionSettings.keyEncryptionKey.keyUrl",
                "exists": false
              },
              {
                "field": "Microsoft.StorageCache/amlFilesystems/encryptionSettings.keyEncryptionKey.keyUrl",
                "equals": ""
              },
              {
                "field": "Microsoft.StorageCache/amlFilesystems/encryptionSettings.keyEncryptionKey.sourceVault.id",
                "exists": false
              },
              {
                "field": "Microsoft.StorageCache/amlFilesystems/encryptionSettings.keyEncryptionKey.sourceVault.id",
                "equals": ""
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/49af39b4-9394-4043-b153-f4a67201368b",
  "name": "49af39b4-9394-4043-b153-f4a67201368b"
}
Bylaw49af39b4-9394-4043-b153-f4a67201368b.bylaw.ps1 · 45 lines
# Converted from AmlFilesystem_CMKEnabled_Audit.json by ConvertTo-Bylaw.
Policy '49af39b4-9394-4043-b153-f4a67201368b' {

    Properties @{
        DisplayName   = '[Preview]: Azure Managed Lustre file systems should use customer-managed keys for encryption'
        Description   = 'Use customer-managed keys to manage encryption at rest for Azure Managed Lustre file systems. Customer-managed keys enable data to be encrypted with Azure Key Vault keys that you own and manage.'
        Version       = '1.0.0-preview'
        Category      = 'Sovereignty'
        Preview       = $true
        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.StorageCache/amlFilesystems' {

        Require 'identity.type is UserAssigned' {
            Field identity.type | Must -Be 'UserAssigned'
        }

        Require 'encryptionSettings.keyEncryptionKey.keyUrl exists' {
            Field encryptionSettings.keyEncryptionKey.keyUrl | Must -Exist
        }

        Require 'encryptionSettings.keyEncryptionKey.keyUrl is not' {
            Field encryptionSettings.keyEncryptionKey.keyUrl | Must -Not -Be '' -IfPresent
        }

        Require 'encryptionSettings.keyEncryptionKey.sourceVault.id exists' {
            Field encryptionSettings.keyEncryptionKey.sourceVault.id | Must -Exist
        }

        Require 'encryptionSettings.keyEncryptionKey.sourceVault.id is not' {
            Field encryptionSettings.keyEncryptionKey.sourceVault.id | Must -Not -Be '' -IfPresent
        }
    }

    Effect (Param Effect)
}

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