Bylaw

Gallery › Network › Azure Community Policy

Deny Bastion Shared Links

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

The Bastion Shareable Link feature lets users connect to a target resource (virtual machine or virtual machine scale set) using Azure Bastion without accessing the Azure portal.

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

Azure Policy JSONazurepolicy.json · 47 lines
{
  "name": "17004589-5ebb-451c-bad8-b50a20ada47b",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Deny Bastion Shared Links",
    "description": "The Bastion Shareable Link feature lets users connect to a target resource (virtual machine or virtual machine scale set) using Azure Bastion without accessing the Azure portal.",
    "metadata": {
      "version": "1.0.0",
      "category": "Network"
    },
    "mode": "All",
    "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": [
          {
            "equals": "microsoft.network/bastionhosts",
            "field": "type"
          },
          {
            "not": {
              "field": "Microsoft.Network/bastionHosts/enableShareableLink",
              "equals": "False"
            }
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw17004589-5ebb-451c-bad8-b50a20ada47b.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '17004589-5ebb-451c-bad8-b50a20ada47b' {

    Properties @{
        DisplayName = 'Deny Bastion Shared Links'
        Description = 'The Bastion Shareable Link feature lets users connect to a target resource (virtual machine or virtual machine scale set) using Azure Bastion without accessing the Azure portal.'
        Version     = '1.0.0'
        Category    = 'Network'
        Mode        = 'All'
    }

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

    Resource 'microsoft.network/bastionhosts' {

        Require 'enableShareableLink is False' {
            Field enableShareableLink | Must -Be 'False'
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Network/deny-bastion-shared-links/azurepolicy.json in Azure/Community-Policy, under the MIT licence.