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

Tag policies #390

Merged
merged 15 commits into from
Oct 20, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "28e5394c-3122-4f50-a926-c7f168f0ebcc",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Validate date tag on subscription",
"description": "Validate a date tag on a subscription, e.g. ExpirationDate, in a YYYY-MM-DD format.",
"metadata": {
"version": "1.0.0",
"category": "Tags"
},
"mode": "All",
"parameters": {
"tagExpirationDate": {
"type": "String",
"metadata": {
"displayName": "tagExpirationDate",
"description": "Name of the tag containing a date value."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
},
{
"field": "[concat('tags[',parameters('tagExpirationDate'), ']')]",
"notMatch": "####-##-##"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"tagExpirationDate": {
"type": "String",
"metadata": {
"displayName": "tagExpirationDate",
"description": "Name of the tag containing a date value."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
},
{
"field": "[concat('tags[',parameters('tagExpirationDate'), ']')]",
"notMatch": "####-##-##"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "151a7585-6199-43c8-887d-5f83dce26aa2",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Validate email tag on subscription",
"description": "Ensure subscription tag value for an email tag follows format *@domain.com.",
"metadata": {
"version": "1.0.0",
"category": "Tags"
},
"mode": "All",
"parameters": {
"tagEmail": {
"type": "String",
"metadata": {
"displayName": "tagEmail",
"description": "Name of the tag containing the email address, e.g. 'SubOwner-Email'"
}
},
"tagValueEmailDomain": {
"type": "String",
"metadata": {
"displayName": "emailDomain",
"description": "Enter the domain name of the email address, e.g. Accenture.com"
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
},
{
"field": "[concat('tags[',parameters('tagEmail'), ']')]",
"notLike": "[concat('*@',parameters('tagValueEmailDomain'))]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"tagEmail": {
"type": "String",
"metadata": {
"displayName": "tagEmail",
"description": "Name of the tag containing the email address, e.g. 'SubOwner-Email'"
}
},
"tagValueEmailDomain": {
"type": "String",
"metadata": {
"displayName": "emailDomain",
"description": "Enter the domain name of the email address, e.g. Accenture.com"
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
},
{
"field": "[concat('tags[',parameters('tagEmail'), ']')]",
"notLike": "[concat('*@',parameters('tagValueEmailDomain'))]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "64b026ea-d1f4-429d-b580-8d41c760bece",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Validate length of subscription tag",
"description": "Validate the length of a subscription tag value.",
"metadata": {
"version": "1.0.0",
"category": "Tags"
},
"mode": "All",
"parameters": {
"tagCostCenter": {
"type": "String",
"metadata": {
"displayName": "tagCostCenter",
"description": "Name of the tag, e.g. CostCenter"
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
},
{
"value": "[string(length(field(concat('tags[', parameters('tagCostCenter'), ']'))))]",
"notEquals": "6"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"tagCostCenter": {
"type": "String",
"metadata": {
"displayName": "tagCostCenter",
"description": "Name of the tag, e.g. CostCenter"
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
},
{
"value": "[string(length(field(concat('tags[', parameters('tagCostCenter'), ']'))))]",
"notEquals": "6"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}