Bylaw

Gallery › Security Center › Azure built-in policies

Configure Microsoft Defender CSPM to be enabled

Converted Policy DeployIfNotExists Disabled Mode All Version 1.0.2

Defender Cloud Security Posture Management (CSPM) provides enhanced posture capabilities and a new intelligent cloud security graph to help identify, prioritize, and reduce risk. Defender CSPM is available in addition to the free foundational security posture capabilities turned on by default in Defender for Cloud.

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

Azure Policy JSONASC_Azure_Defender_CSPM_DINE.json · 78 lines
{
  "properties": {
    "displayName": "Configure Microsoft Defender CSPM to be enabled",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Defender Cloud Security Posture Management (CSPM) provides enhanced posture capabilities and a new intelligent cloud security graph to help identify, prioritize, and reduce risk. Defender CSPM is available in addition to the free foundational security posture capabilities turned on by default in Defender for Cloud.",
    "metadata": {
      "version": "1.0.2",
      "category": "Security Center"
    },
    "version": "1.0.2",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "DeployIfNotExists",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ]
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Resources/subscriptions"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/pricings",
          "name": "CloudPosture",
          "deploymentScope": "subscription",
          "existenceScope": "subscription",
          "roleDefinitionIds": [
            "/providers/Microsoft.Authorization/roleDefinitions/8e3af657-a8ff-443c-a75c-2fe8c4bcb635"
          ],
          "existenceCondition": {
            "field": "Microsoft.Security/pricings/pricingTier",
            "equals": "Standard"
          },
          "deployment": {
            "location": "westeurope",
            "properties": {
              "mode": "incremental",
              "parameters": {},
              "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {},
                "variables": {},
                "resources": [
                  {
                    "type": "Microsoft.Security/pricings",
                    "apiVersion": "2023-01-01",
                    "name": "CloudPosture",
                    "properties": {
                      "pricingTier": "Standard"
                    }
                  }
                ],
                "outputs": {}
              }
            }
          }
        }
      }
    },
    "versions": [
      "1.0.2"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/689f7782-ef2c-4270-a6d0-7664869076bd",
  "name": "689f7782-ef2c-4270-a6d0-7664869076bd"
}
Bylaw689f7782-ef2c-4270-a6d0-7664869076bd.bylaw.ps1 · 33 lines
# Converted from ASC_Azure_Defender_CSPM_DINE.json by ConvertTo-Bylaw.
Policy '689f7782-ef2c-4270-a6d0-7664869076bd' {

    Properties @{
        DisplayName   = 'Configure Microsoft Defender CSPM to be enabled'
        Description   = 'Defender Cloud Security Posture Management (CSPM) provides enhanced posture capabilities and a new intelligent cloud security graph to help identify, prioritize, and reduce risk. Defender CSPM is available in addition to the free foundational security posture capabilities turned on by default in Defender for Cloud.'
        Version       = '1.0.2'
        Category      = 'Security Center'
        PolicyVersion = '1.0.2'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.Resources/subscriptions'

    DeployIfNotExists 'Microsoft.Security/pricings' -Role 'Owner' -Name 'CloudPosture' -ExistenceScope Subscription -Effect (Param Effect) {
        Require 'pricingTier is Standard' {
            Field pricingTier | Must -Be 'Standard'
        }
        Deployment @{
            TemplateFile = './templates/689f7782-ef2c-4270-a6d0-7664869076bd.json'
            Scope        = 'Subscription'
            Location     = 'westeurope'
        }
    }
}

Its deployment templates are written beside it:

Source: built-in-policies/policyDefinitions/Security Center/ASC_Azure_Defender_CSPM_DINE.json in Azure/azure-policy, under the MIT licence.