forked from Azure/CanadaPubSecALZ
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Tag inheritance from Subscription to Resource Group (Azur…
…e#161) * Add policy and policy set to inherit tags from subscription to resource group * Add branch config for testing * Remove policy type as it's not built in * Updated resource type for resource group * Update policy assignment * Ensure assignment name is <= 24 chars * Revert resource group type * Setting mode to all * Update documentation * Add branch config * Add explicit dependsOn for subscription scaffolding to complete * Update test deployment parameters * Remove explicit dependsOn for subscription scaffolding to complete * Update doc to describe approaches for adding tags to RGs * Reduce the options for tagging resources given subscripton to RG tagging is available * Add example scenarios for tag inheritence * Fix typo * Remove branch configs * Resolve linter error: no-loc-expr-outside-params
- Loading branch information
1 parent
e71ed26
commit edabd87
Showing
7 changed files
with
160 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
.../policyset/templates/Tags-Inherit-Tag-From-Subscription-To-ResourceGroup/azurepolicy.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"type": "Microsoft.Authorization/policyDefinitions", | ||
"name": "Tags-Inherit-Tag-From-Subscription-To-ResourceGroup", | ||
"properties": { | ||
"displayName": "Inherit a tag from the subscription to resource group if missing", | ||
"mode": "All", | ||
"description": "Adds the specified tag with its value from the containing subscription when any resource group is missing this tag is created or updated. If the tag exists with a different value it will not be changed.", | ||
"parameters": { | ||
"tagName": { | ||
"type": "String", | ||
"metadata": { | ||
"displayName": "Tag Name", | ||
"description": "Name of the tag, such as 'environment'" | ||
} | ||
} | ||
}, | ||
"policyRule": { | ||
"if": { | ||
"allOf": [ | ||
{ | ||
"field": "type", | ||
"equals": "Microsoft.Resources/subscriptions/resourceGroups" | ||
}, | ||
{ | ||
"field": "[concat('tags[', parameters('tagName'), ']')]", | ||
"exists": "false" | ||
}, | ||
{ | ||
"value": "[subscription().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": "[subscription().tags[parameters('tagName')]]" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |