Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support to Create ARM Template for policyDefinitions #776

Open
uday31in opened this issue Mar 15, 2023 · 0 comments
Open

Add Support to Create ARM Template for policyDefinitions #776

uday31in opened this issue Mar 15, 2023 · 0 comments
Labels
area/powershell enhancement New feature or request

Comments

@uday31in
Copy link
Member

uday31in commented Mar 15, 2023

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": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/powershell enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants