Bylaw

Gallery › BuiltInPolicyTest › Azure built-in policies

Ensures resources to not have a specific tag. This is a versioning test built-in.

Converted Initiative Version 2.0.1

Denies the creation of a resource that contains the given tag. Does not apply to resource groups.

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

Azure Policy JSONDenyTag.json · 58 lines
{
  "properties": {
    "displayName": "Ensures resources to not have a specific tag. This is a versioning test built-in.",
    "policyType": "BuiltIn",
    "description": "Denies the creation of a resource that contains the given tag. Does not apply to resource groups.",
    "metadata": {
      "version": "2.0.1",
      "category": "BuiltInPolicyTest"
    },
    "version": "2.0.1",
    "parameters": {
      "tagName": {
        "type": "String",
        "metadata": {
          "displayName": "Tag Name",
          "description": "Name of the tag."
        }
      },
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionReferenceId": "DenyTag",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/36fd7371-8eb7-4321-9c30-a7100022d048",
        "definitionVersion": "2.*.*",
        "parameters": {
          "tagName": {
            "value": "[parameters('tagName')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          }
        }
      }
    ],
    "versions": [
      "2.0.1",
      "2.0.0",
      "1.1.1",
      "1.0.1",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policySetDefinitions/1bb84455-9e6e-434c-8db6-fa6d03a67e87",
  "name": "1bb84455-9e6e-434c-8db6-fa6d03a67e87"
}
Bylaw1bb84455-9e6e-434c-8db6-fa6d03a67e87.bylaw.ps1 · 33 lines
# Converted from DenyTag.json by ConvertTo-Bylaw.
Initiative '1bb84455-9e6e-434c-8db6-fa6d03a67e87' {

    Properties @{
        DisplayName   = 'Ensures resources to not have a specific tag. This is a versioning test built-in.'
        Description   = 'Denies the creation of a resource that contains the given tag. Does not apply to resource groups.'
        Version       = '2.0.1'
        Category      = 'BuiltInPolicyTest'
        PolicyVersion = '2.0.1'
    }

    Parameter TagName @{
        Type        = 'String'
        DisplayName = 'Tag Name'
        Description = 'Name of the tag.'
    }
    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    PolicyDefinition @{
        Id          = '36fd7371-8eb7-4321-9c30-a7100022d048'
        ReferenceId = 'DenyTag'
        Version     = '2.*.*'
        Parameters  = [ordered]@{
            tagName = (Param TagName)
            effect  = (Param Effect)
        }
    }
}

Members (1)

Source: built-in-policies/policySetDefinitions/BuiltInPolicyTest/DenyTag.json in Azure/azure-policy, under the MIT licence.