Skip to content

Commit

Permalink
Audit - StorageAccounts Should Have Lifecycle Policy Enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
danielorn committed Sep 26, 2023
1 parent e1ea8ba commit 604991d
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "bc1e3f2c-692d-4e3e-ab47-9273a71d8079",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit - StorageAccounts Should Have Lifecycle Policy Enabled",
"description": "This policy audits storage accounts that do not have at least one management policy of type lifecycle enabled.",
"metadata": {
"version": "1.0.0",
"category": "Storage"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Storage/storageAccounts"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"name": "[concat(field('name'), '/default')]",
"existenceCondition": {
"count": {
"field": "Microsoft.Storage/storageAccounts/managementPolicies/policy.rules[*]",
"where": {
"allOf": [
{
"field": "Microsoft.Storage/storageAccounts/managementPolicies/policy.rules[*].enabled",
"equals": true
},
{
"field": "Microsoft.Storage/storageAccounts/managementPolicies/policy.rules[*].type",
"equals": "Lifecycle"
}
]
}
},
"greater": 0
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"if": {
"field": "type",
"equals": "Microsoft.Storage/storageAccounts"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"name": "[concat(field('name'), '/default')]",
"existenceCondition": {
"count": {
"field": "Microsoft.Storage/storageAccounts/managementPolicies/policy.rules[*]",
"where": {
"allOf": [
{
"field": "Microsoft.Storage/storageAccounts/managementPolicies/policy.rules[*].enabled",
"equals": true
},
{
"field": "Microsoft.Storage/storageAccounts/managementPolicies/policy.rules[*].type",
"equals": "Lifecycle"
}
]
}
},
"greater": 0
}
}
}
}

0 comments on commit 604991d

Please sign in to comment.