Gallery › Sovereignty › Azure built-in policies
[Preview]: Azure Red Hat OpenShift clusters 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 Red Hat OpenShift clusters. Customer-managed keys enable data to be encrypted using a disk encryption set that you control, including key rotation and management. Existing clusters created without customer-managed keys for master nodes cannot enable them later and must be recreated to comply.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONOpenShiftCluster_CMK_Audit.json · 77 lines
{
"properties": {
"displayName": "[Preview]: Azure Red Hat OpenShift clusters 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 Red Hat OpenShift clusters. Customer-managed keys enable data to be encrypted using a disk encryption set that you control, including key rotation and management. Existing clusters created without customer-managed keys for master nodes cannot enable them later and must be recreated to comply.",
"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.RedHatOpenShift/openShiftClusters"
},
{
"anyOf": [
{
"field": "Microsoft.RedHatOpenShift/openShiftClusters/masterProfile.diskEncryptionSetId",
"exists": false
},
{
"field": "Microsoft.RedHatOpenShift/openShiftClusters/masterProfile.diskEncryptionSetId",
"equals": ""
},
{
"value": "[length(field('Microsoft.RedHatOpenShift/openShiftClusters/workerProfiles[*]'))]",
"equals": 0
},
{
"value": "[length(field('Microsoft.RedHatOpenShift/openShiftClusters/workerProfiles[*].diskEncryptionSetId'))]",
"notEquals": "[length(field('Microsoft.RedHatOpenShift/openShiftClusters/workerProfiles[*]'))]"
},
{
"count": {
"field": "Microsoft.RedHatOpenShift/openShiftClusters/workerProfiles[*]",
"where": {
"value": "[current('Microsoft.RedHatOpenShift/openShiftClusters/workerProfiles[*].diskEncryptionSetId')]",
"equals": ""
}
},
"greater": 0
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/ea4d0edd-1555-4917-8d8f-042f98fa6a0e",
"name": "ea4d0edd-1555-4917-8d8f-042f98fa6a0e"
}Bylawea4d0edd-1555-4917-8d8f-042f98fa6a0e.bylaw.ps1 · 47 lines
# Converted from OpenShiftCluster_CMK_Audit.json by ConvertTo-Bylaw.
Policy 'ea4d0edd-1555-4917-8d8f-042f98fa6a0e' {
Properties @{
DisplayName = '[Preview]: Azure Red Hat OpenShift clusters should use customer-managed keys to encrypt data at rest'
Description = 'Use customer-managed keys to manage encryption at rest for Azure Red Hat OpenShift clusters. Customer-managed keys enable data to be encrypted using a disk encryption set that you control, including key rotation and management. Existing clusters created without customer-managed keys for master nodes cannot enable them later and must be recreated to comply.'
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.RedHatOpenShift/openShiftClusters' {
Require 'masterProfile.diskEncryptionSetId exists' {
Field masterProfile.diskEncryptionSetId | Must -Exist
}
Require 'masterProfile.diskEncryptionSetId is not' {
Field masterProfile.diskEncryptionSetId | Must -Not -Be '' -IfPresent
}
Require 'workerProfiles is as required' {
Arm '[length(field(''Microsoft.RedHatOpenShift/openShiftClusters/workerProfiles[*]''))]' | Must -Not -Be 0
}
Require 'workerProfiles.diskEncryptionSetId and workerProfiles are as required' {
Arm '[length(field(''Microsoft.RedHatOpenShift/openShiftClusters/workerProfiles[*].diskEncryptionSetId''))]' | Must -Be (Arm '[length(field(''Microsoft.RedHatOpenShift/openShiftClusters/workerProfiles[*]''))]')
}
Require 'workerProfiles is as required' {
Count 'workerProfiles[*]' -Where {
Arm '[current(''Microsoft.RedHatOpenShift/openShiftClusters/workerProfiles[*].diskEncryptionSetId'')]' | Must -Be ''
} | Must -Be 0
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Sovereignty/OpenShiftCluster_CMK_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw