-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Storage Account Management Policy module
- Loading branch information
Showing
4 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
src/carml/v0.6.0/Storage/storage-account/management-policy/README.md
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,71 @@ | ||
# Storage Account Management Policies `[Microsoft.Storage/storageAccounts/managementPolicies]` | ||
|
||
This module deploys a Storage Account Management Policy. | ||
|
||
## Navigation | ||
|
||
- [Resource Types](#resource-types) | ||
- [Parameters](#parameters) | ||
- [Outputs](#outputs) | ||
- [Cross-referenced modules](#cross-referenced-modules) | ||
|
||
## Resource Types | ||
|
||
| Resource Type | API Version | | ||
| :-- | :-- | | ||
| `Microsoft.Storage/storageAccounts/managementPolicies` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/storageAccounts/managementPolicies) | | ||
|
||
## Parameters | ||
|
||
**Required parameters** | ||
|
||
| Parameter | Type | Description | | ||
| :-- | :-- | :-- | | ||
| [`rules`](#parameter-rules) | array | The Storage Account ManagementPolicies Rules. | | ||
|
||
**Conditional parameters** | ||
|
||
| Parameter | Type | Description | | ||
| :-- | :-- | :-- | | ||
| [`storageAccountName`](#parameter-storageaccountname) | string | The name of the parent Storage Account. Required if the template is used in a standalone deployment. | | ||
|
||
**Optional parameters** | ||
|
||
| Parameter | Type | Description | | ||
| :-- | :-- | :-- | | ||
| [`enableDefaultTelemetry`](#parameter-enabledefaulttelemetry) | bool | Enable telemetry via a Globally Unique Identifier (GUID). | | ||
|
||
### Parameter: `rules` | ||
|
||
The Storage Account ManagementPolicies Rules. | ||
|
||
- Required: Yes | ||
- Type: array | ||
|
||
### Parameter: `storageAccountName` | ||
|
||
The name of the parent Storage Account. Required if the template is used in a standalone deployment. | ||
|
||
- Required: Yes | ||
- Type: string | ||
|
||
### Parameter: `enableDefaultTelemetry` | ||
|
||
Enable telemetry via a Globally Unique Identifier (GUID). | ||
|
||
- Required: No | ||
- Type: bool | ||
- Default: `True` | ||
|
||
|
||
## Outputs | ||
|
||
| Output | Type | Description | | ||
| :-- | :-- | :-- | | ||
| `name` | string | The name of the deployed management policy. | | ||
| `resourceGroupName` | string | The resource group of the deployed management policy. | | ||
| `resourceId` | string | The resource ID of the deployed management policy. | | ||
|
||
## Cross-referenced modules | ||
|
||
_None_ |
49 changes: 49 additions & 0 deletions
49
src/carml/v0.6.0/Storage/storage-account/management-policy/main.bicep
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,49 @@ | ||
metadata name = 'Storage Account Management Policies' | ||
metadata description = 'This module deploys a Storage Account Management Policy.' | ||
metadata owner = 'Azure/module-maintainers' | ||
|
||
@maxLength(24) | ||
@description('Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment.') | ||
param storageAccountName string | ||
|
||
@description('Required. The Storage Account ManagementPolicies Rules.') | ||
param rules array | ||
|
||
@description('Optional. Enable telemetry via a Globally Unique Identifier (GUID).') | ||
param enableDefaultTelemetry bool = true | ||
|
||
resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) { | ||
name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name)}' | ||
properties: { | ||
mode: 'Incremental' | ||
template: { | ||
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#' | ||
contentVersion: '1.0.0.0' | ||
resources: [] | ||
} | ||
} | ||
} | ||
|
||
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' existing = { | ||
name: storageAccountName | ||
} | ||
|
||
// lifecycle policy | ||
resource managementPolicy 'Microsoft.Storage/storageAccounts/managementPolicies@2023-01-01' = if (!empty(rules)) { | ||
name: 'default' | ||
parent: storageAccount | ||
properties: { | ||
policy: { | ||
rules: rules | ||
} | ||
} | ||
} | ||
|
||
@description('The resource ID of the deployed management policy.') | ||
output resourceId string = managementPolicy.name | ||
|
||
@description('The name of the deployed management policy.') | ||
output name string = managementPolicy.name | ||
|
||
@description('The resource group of the deployed management policy.') | ||
output resourceGroupName string = resourceGroup().name |
86 changes: 86 additions & 0 deletions
86
src/carml/v0.6.0/Storage/storage-account/management-policy/main.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,86 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"metadata": { | ||
"_generator": { | ||
"name": "bicep", | ||
"version": "0.23.1.45101", | ||
"templateHash": "9776092818963506976" | ||
}, | ||
"name": "Storage Account Management Policies", | ||
"description": "This module deploys a Storage Account Management Policy.", | ||
"owner": "Azure/module-maintainers" | ||
}, | ||
"parameters": { | ||
"storageAccountName": { | ||
"type": "string", | ||
"maxLength": 24, | ||
"metadata": { | ||
"description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment." | ||
} | ||
}, | ||
"rules": { | ||
"type": "array", | ||
"metadata": { | ||
"description": "Required. The Storage Account ManagementPolicies Rules." | ||
} | ||
}, | ||
"enableDefaultTelemetry": { | ||
"type": "bool", | ||
"defaultValue": true, | ||
"metadata": { | ||
"description": "Optional. Enable telemetry via a Globally Unique Identifier (GUID)." | ||
} | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
"condition": "[parameters('enableDefaultTelemetry')]", | ||
"type": "Microsoft.Resources/deployments", | ||
"apiVersion": "2021-04-01", | ||
"name": "[format('pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-{0}', uniqueString(deployment().name))]", | ||
"properties": { | ||
"mode": "Incremental", | ||
"template": { | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"resources": [] | ||
} | ||
} | ||
}, | ||
{ | ||
"condition": "[not(empty(parameters('rules')))]", | ||
"type": "Microsoft.Storage/storageAccounts/managementPolicies", | ||
"apiVersion": "2023-01-01", | ||
"name": "[format('{0}/{1}', parameters('storageAccountName'), 'default')]", | ||
"properties": { | ||
"policy": { | ||
"rules": "[parameters('rules')]" | ||
} | ||
} | ||
} | ||
], | ||
"outputs": { | ||
"resourceId": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The resource ID of the deployed management policy." | ||
}, | ||
"value": "default" | ||
}, | ||
"name": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The name of the deployed management policy." | ||
}, | ||
"value": "default" | ||
}, | ||
"resourceGroupName": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The resource group of the deployed management policy." | ||
}, | ||
"value": "[resourceGroup().name]" | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/carml/v0.6.0/Storage/storage-account/management-policy/version.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,7 @@ | ||
{ | ||
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", | ||
"version": "0.4", | ||
"pathFilters": [ | ||
"./main.json" | ||
] | ||
} |