Skip to content

Add Support to Create ARM Template for policyDefinitions #776

Description

@uday31in

Describe the solution you'd like

At the moment, due to string escape requirement for policyRule, policyDefinitions Templates are generated as parameter file.

It would be great to have policyDefinitions generated as ARM template. Following JQ Template can help with that

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "metadata": {
        "_generator": {
            "name": "AzOps"
        }
    },
    "parameters": {},
    "variables": {},
    "resources": [
        {
            "type": .Type,
            "name": .name,
            "apiVersion": "2021-06-01",
            "properties": {
                "description": .properties.description,
                "displayName":  .properties.displayName,
                "metadata": {
                    "version": .properties.metadata.version,
                    "category": .properties.metadata.category
                },
                "mode": .properties.mode,
                "parameters": .properties.parameters,
                "policyRule": .properties.policyRule | walk(if type == "string" and (.|startswith("[")) then "[" + sub("^\\["; "[") else . end),
                "policyType": .properties.policyType
            }
        }
    ],
    "outputs": {}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions