Gallery › Mission › Azure built-in policies
Managed Disks and Images should use customer-managed keys for encryption at rest
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. Use customer-managed keys to manage the encryption at rest of the contents of your managed disks and images. By default, the data is encrypted at rest with platform-managed keys, but customer-managed keys are commonly required to meet regulatory compliance standards.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONComputeEncryptDiskAndImages_Audit.json · 128 lines
{
"properties": {
"displayName": "Managed Disks and Images should use customer-managed keys for encryption at rest",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Use customer-managed keys to manage the encryption at rest of the contents of your managed disks and images. By default, the data is encrypted at rest with platform-managed keys, but customer-managed keys are commonly required to meet regulatory compliance standards.",
"metadata": {
"category": "Mission",
"version": "1.0.0"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "customer-managed keys to manage the encryption at rest effect",
"description": "Enable or disable the customer-managed keys to manage the encryption at rest effect"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"anyOf": [
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/disks"
},
{
"field": "Microsoft.Compute/disks/encryption.diskEncryptionSetId",
"exists": "False"
}
]
},
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/galleries/images/versions"
},
{
"value": "[length(field('Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*].encryption.osDiskImage.diskEncryptionSetId'))]",
"notEquals": "[length(field('Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*]'))]"
}
]
},
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/galleries/images/versions"
},
{
"value": "[length(field('Microsoft.Compute/galleries/images/versions/storageProfile.dataDiskImages[*]'))]",
"greater": 0
},
{
"anyOf": [
{
"count": {
"field": "Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*]",
"where": {
"value": "[length(current('Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*].encryption.dataDiskImages[*].diskEncryptionSetId'))]",
"notEquals": "[length(field('Microsoft.Compute/galleries/images/versions/storageProfile.dataDiskImages[*]'))]"
}
},
"greater": 0
},
{
"not": {
"field": "Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*].encryption.dataDiskImages[*].diskEncryptionSetId",
"exists": "true"
}
}
]
}
]
},
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/images"
},
{
"field": "Microsoft.Compute/images/storageProfile.osDisk.diskEncryptionSet.id",
"exists": "False"
}
]
},
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/images"
},
{
"value": "[length(field('Microsoft.Compute/images/storageProfile.dataDisks[*]'))]",
"greater": 0
},
{
"not": {
"field": "Microsoft.Compute/images/storageProfile.dataDisks[*].diskEncryptionSet.id",
"exists": "true"
}
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/59953f11-df7f-48b1-870f-1780ed07348e",
"name": "59953f11-df7f-48b1-870f-1780ed07348e"
}Bylaw59953f11-df7f-48b1-870f-1780ed07348e.bylaw.ps1 · 77 lines
# Converted from ComputeEncryptDiskAndImages_Audit.json by ConvertTo-Bylaw.
Policy '59953f11-df7f-48b1-870f-1780ed07348e' {
Properties @{
DisplayName = 'Managed Disks and Images should use customer-managed keys for encryption at rest'
Description = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Use customer-managed keys to manage the encryption at rest of the contents of your managed disks and images. By default, the data is encrypted at rest with platform-managed keys, but customer-managed keys are commonly required to meet regulatory compliance standards.'
Category = 'Mission'
Version = '1.0.0'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Audit'
DisplayName = 'customer-managed keys to manage the encryption at rest effect'
Description = 'Enable or disable the customer-managed keys to manage the encryption at rest effect'
}
Resource * {
Require 'type and encryption.diskEncryptionSetId are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Compute/disks' -IfPresent
Field 'Microsoft.Compute/disks/encryption.diskEncryptionSetId' | Must -Exist
}
}
Require 'type, publishingProfile.targetRegions.encryption.osDiskImage.diskEncryptionSetId and publishingProfile.targetRegions are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Compute/galleries/images/versions' -IfPresent
Arm '[length(field(''Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*].encryption.osDiskImage.diskEncryptionSetId''))]' | Must -Be (Arm '[length(field(''Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*]''))]')
}
}
Require 'type, publishingProfile.targetRegions, encryption.dataDiskImages and 2 more are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Compute/galleries/images/versions' -IfPresent
Arm '[length(field(''Microsoft.Compute/galleries/images/versions/storageProfile.dataDiskImages[*]''))]' | Must -BeLessOrEqual 0
AllOf {
Count 'Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*]' -Where {
Arm '[length(current(''Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*].encryption.dataDiskImages[*].diskEncryptionSetId''))]' | Must -Not -Be (Arm '[length(field(''Microsoft.Compute/galleries/images/versions/storageProfile.dataDiskImages[*]''))]')
} | Must -Be 0
Field 'Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions' | Must -Exist
Each 'Microsoft.Compute/galleries/images/versions/publishingProfile.targetRegions[*]' {
Field encryption.dataDiskImages | Must -Exist
Each 'encryption.dataDiskImages[*]' {
Field diskEncryptionSetId | Must -Exist
}
}
}
}
}
Require 'type and storageProfile.osDisk.diskEncryptionSet.id are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Compute/images' -IfPresent
Field 'Microsoft.Compute/images/storageProfile.osDisk.diskEncryptionSet.id' | Must -Exist
}
}
Require 'type, storageProfile.dataDisks and diskEncryptionSet.id are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Compute/images' -IfPresent
Arm '[length(field(''Microsoft.Compute/images/storageProfile.dataDisks[*]''))]' | Must -BeLessOrEqual 0
AllOf {
Field 'Microsoft.Compute/images/storageProfile.dataDisks' | Must -Exist
Each 'Microsoft.Compute/images/storageProfile.dataDisks[*]' {
Field diskEncryptionSet.id | Must -Exist
}
}
}
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Mission/ComputeEncryptDiskAndImages_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw