Bylaw

Gallery › Storage › Azure Landing Zones Library

Storage Accounts with SFTP enabled should be denied

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy denies the creation of Storage Accounts with SFTP enabled for Blob Storage.

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

Azure Policy JSONDeny-Storage-SFTP.alz_policy_definition.json · 52 lines
{
  "name": "Deny-Storage-SFTP",
  "properties": {
    "description": "This policy denies the creation of Storage Accounts with SFTP enabled for Blob Storage.",
    "displayName": "Storage Accounts with SFTP enabled should be denied",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Storage",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.0"
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "The effect determines what happens when the policy rule is evaluated to match",
          "displayName": "Effect"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Storage/storageAccounts",
            "field": "type"
          },
          {
            "equals": "true",
            "field": "Microsoft.Storage/storageAccounts/isSftpEnabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-Storage-SFTP.bylaw.ps1 · 28 lines
# Converted from Deny-Storage-SFTP.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-Storage-SFTP' {

    Properties @{
        DisplayName = 'Storage Accounts with SFTP enabled should be denied'
        Description = 'This policy denies the creation of Storage Accounts with SFTP enabled for Blob Storage.'
        Category    = 'Storage'
        Version     = '1.0.0'
        Mode        = 'Indexed'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.Storage/storageAccounts' {

        Require 'isSftpEnabled is not true' {
            Field isSftpEnabled | Must -Not -Be 'true' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policy_definitions/Deny-Storage-SFTP.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.