Bylaw

Gallery › SQL › Azure Community Policy

Enforce SSL on all DB for MySQL instances

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy ensures SSL is enforced on all DB for MySQL instances

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

Azure Policy JSONazurepolicy.json · 45 lines
{
  "name": "8bb602c2-928b-4755-adb5-cff9868efb7a",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Enforce SSL on all DB for MySQL instances",
    "description": "This policy ensures SSL is enforced on all DB for MySQL instances",
    "metadata": {
      "category": "SQL",
      "version": "1.0.0"
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.DBforMySQL/servers"
          },
          {
            "field": "Microsoft.DBforMySQL/servers/sslEnforcement",
            "equals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw8bb602c2-928b-4755-adb5-cff9868efb7a.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '8bb602c2-928b-4755-adb5-cff9868efb7a' {

    Properties @{
        DisplayName = 'Enforce SSL on all DB for MySQL instances'
        Description = 'This policy ensures SSL is enforced on all DB for MySQL instances'
        Category    = 'SQL'
        Version     = '1.0.0'
        Mode        = 'Indexed'
    }

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

    Resource 'Microsoft.DBforMySQL/servers' {

        Require 'sslEnforcement is not Disabled' {
            Field sslEnforcement | Must -Not -Be 'Disabled' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/SQL/enforce-ssl-on-all-db-for-mysql-instances/azurepolicy.json in Azure/Community-Policy, under the MIT licence.