{
   "properties": {
      "displayName": "Inherit a tag from the resource group if missing",
      "policyType": "BuiltIn",
      "mode": "Indexed",
      "description": "Adds the specified tag with its value from the parent resource group when any resource missing this tag is created or updated. Existing resources can be remediated by triggering a remediation task. If the tag exists with a different value it will not be changed.",
      "metadata": {
         "version": "1.0.0",
         "category": "Tags"
      },
      "parameters": {
         "tagName": {
            "type": "String",
            "metadata": {
               "displayName": "Tag Name",
               "description": "Name of the tag, such as 'environment'"
            }
         }
      },
      "policyRule": {
         "if": {
            "allOf": [
               {
                  "field": "[concat('tags[', parameters('tagName'), ']')]",
                  "exists": "false"
               },
               {
                  "value": "[resourceGroup().tags[parameters('tagName')]]",
                  "notEquals": ""
               }
            ]
         },
         "then": {
            "effect": "modify",
            "details": {
               "roleDefinitionIds": [
                  "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
               ],
               "operations": [
                  {
                     "operation": "add",
                     "field": "[concat('tags[', parameters('tagName'), ']')]",
                     "value": "[resourceGroup().tags[parameters('tagName')]]"
                  }
               ]
            }
         }
      }
   },
   "id": "/providers/Microsoft.Authorization/policyDefinitions/ea3f2387-9b95-492a-a190-fcdc54f7b070",
   "name": "ea3f2387-9b95-492a-a190-fcdc54f7b070"
}