Gallery › Mission › Azure built-in policies
Storage account should restrict source and destination targets for specified storage account object replication policies.
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Restrict Source and Destination Targets for Specified Storage Account Object Replication Policies. storageAccountTargets is an array of objects with Storage Account Name, Source Storage Account Names, and Destination Storage Account Names.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONStorageRestrictReplicationTargets_Audit.json · 94 lines
{
"properties": {
"displayName": "Storage account should restrict source and destination targets for specified storage account object replication policies.",
"policyType": "BuiltIn",
"mode": "All",
"description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Restrict Source and Destination Targets for Specified Storage Account Object Replication Policies. storageAccountTargets is an array of objects with Storage Account Name, Source Storage Account Names, and Destination Storage Account Names. ",
"metadata": {
"version": "1.0.0",
"category": "Mission"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Storage account should restrict source and destination targets for specified storage account object replication policies. effect",
"description": "Enforce Storage account should restrict source and destination targets for specified storage account object replication policies. effect"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
},
"storageAccountTargets": {
"type": "Array",
"metadata": {
"description": "An array of objects specifying governed storage accounts and their approved object replication source/destination pairs. Each element has the shape: { \"saName\": \"<governed storage account name>\", \"sourceSAs\": [\"<approved source storage account name>\", ...], \"destSAs\": [\"<approved destination storage account name>\", ...] }. Example: [{ \"saName\": \"governedSA1\", \"sourceSAs\": [\"srcSA-a\"], \"destSAs\": [\"dstSA-x\"] }].",
"displayName": "Targeted Storage Accounts"
},
"defaultValue": []
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Storage/storageAccounts/objectReplicationPolicies"
},
{
"not": {
"anyOf": [
{
"count": {
"value": "[parameters('storageAccountTargets')]",
"name": "storageAccountTargets",
"where": {
"field": "fullName",
"like": "[concat(current('storageAccountTargets').saName,'/*')]"
}
},
"equals": 0
},
{
"count": {
"value": "[parameters('storageAccountTargets')]",
"name": "storageAccountTargets",
"where": {
"allOf": [
{
"field": "fullName",
"like": "[concat(current('storageAccountTargets').saName,'/*')]"
},
{
"value": "[split(field('Microsoft.Storage/storageAccounts/objectReplicationPolicies/sourceAccount'),'/')[8]]",
"in": "[array(current('storageAccountTargets').sourceSAs)]"
},
{
"value": "[split(field('Microsoft.Storage/storageAccounts/objectReplicationPolicies/destinationAccount'), '/')[8]]",
"in": "[array(current('storageAccountTargets').destSAs)]"
}
]
}
},
"greater": 0
}
]
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/0191f0f3-c1e5-4891-a2b4-908bb77b3c29",
"name": "0191f0f3-c1e5-4891-a2b4-908bb77b3c29"
}Bylaw0191f0f3-c1e5-4891-a2b4-908bb77b3c29.bylaw.ps1 · 43 lines
# Converted from StorageRestrictReplicationTargets_Audit.json by ConvertTo-Bylaw.
Policy '0191f0f3-c1e5-4891-a2b4-908bb77b3c29' {
Properties @{
DisplayName = 'Storage account should restrict source and destination targets for specified storage account object replication policies.'
Description = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Restrict Source and Destination Targets for Specified Storage Account Object Replication Policies. storageAccountTargets is an array of objects with Storage Account Name, Source Storage Account Names, and Destination Storage Account Names. '
Version = '1.0.0'
Category = 'Mission'
PolicyVersion = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Audit'
DisplayName = 'Storage account should restrict source and destination targets for specified storage account object replication policies. effect'
Description = 'Enforce Storage account should restrict source and destination targets for specified storage account object replication policies. effect'
}
Parameter StorageAccountTargets @{
Type = 'Array'
Default = @()
DisplayName = 'Targeted Storage Accounts'
Description = 'An array of objects specifying governed storage accounts and their approved object replication source/destination pairs. Each element has the shape: { "saName": "<governed storage account name>", "sourceSAs": ["<approved source storage account name>", ...], "destSAs": ["<approved destination storage account name>", ...] }. Example: [{ "saName": "governedSA1", "sourceSAs": ["srcSA-a"], "destSAs": ["dstSA-x"] }].'
}
Resource 'Microsoft.Storage/storageAccounts/objectReplicationPolicies' {
Require 'fullName, sourceAccount and destinationAccount are as required' {
AnyOf {
Count -Value (Param StorageAccountTargets) -Name storageAccountTargets -Where {
Field fullName | Must -BeLike (Arm '[concat(current(''storageAccountTargets'').saName,''/*'')]')
} | Must -Be 0
Count -Value (Param StorageAccountTargets) -Name storageAccountTargets -Where {
Field fullName | Must -BeLike (Arm '[concat(current(''storageAccountTargets'').saName,''/*'')]')
Arm '[split(field(''Microsoft.Storage/storageAccounts/objectReplicationPolicies/sourceAccount''),''/'')[8]]' | Must -BeIn (Arm '[array(current(''storageAccountTargets'').sourceSAs)]')
Arm '[split(field(''Microsoft.Storage/storageAccounts/objectReplicationPolicies/destinationAccount''), ''/'')[8]]' | Must -BeIn (Arm '[array(current(''storageAccountTargets'').destSAs)]')
} | Must -BeGreaterThan 0
}
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Mission/StorageRestrictReplicationTargets_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw