Skip to content

Commit

Permalink
fix: storage-account module - fixing `requireInfrastructureEncryption…
Browse files Browse the repository at this point in the history
…` issue (#1010)

## Description

Resolves #846 

| Pipeline |
| - |
|
[![avm.res.storage.storage-account](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.storage.storage-account.yml/badge.svg?branch=users%2Fkrbar%2F846_storageFix)](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.storage.storage-account.yml)
|

## Updating an existing module

<!--Run through the checklist if your PR updates an existing module.-->

- [x] This is a bug fix:
- [x] Someone has opened a bug report issue, and I have included "Closes
#846" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] I have run `brm validate` locally to verify the module files.
- [x] I have run deployment tests locally to ensure the module is
deployable.
- [x] I have read the [Updating an existing
module](https://github.com/Azure/bicep-registry-modules/blob/main/CONTRIBUTING.md#updating-an-existing-module)
section in the contributing guide and updated the `version.json` file
properly:
- [x] The PR contains backwards compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`.
- [ ] The PR contains backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] The PR contains breaking changes, and I have bumped the MAJOR
version in `version.json`.
- [ ] I have updated the examples in README with the latest module
version number.
  • Loading branch information
krbar authored Feb 16, 2024
1 parent 768cb8d commit 6a028e3
Show file tree
Hide file tree
Showing 18 changed files with 71 additions and 88 deletions.
4 changes: 2 additions & 2 deletions avm/res/storage/storage-account/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ This module deploys a Storage Account.
| `Microsoft.Storage/storageAccounts/blobServices/containers` | [2022-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2022-09-01/storageAccounts/blobServices/containers) |
| `Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies` | [2022-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2022-09-01/storageAccounts/blobServices/containers/immutabilityPolicies) |
| `Microsoft.Storage/storageAccounts/fileServices` | [2021-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2021-09-01/storageAccounts/fileServices) |
| `Microsoft.Storage/storageAccounts/fileServices/shares` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/storageAccounts/fileServices/shares) |
| `Microsoft.Storage/storageAccounts/fileServices/shares` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2023-01-01/storageAccounts/fileServices/shares) |
| `Microsoft.Storage/storageAccounts/localUsers` | [2022-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2022-05-01/storageAccounts/localUsers) |
| `Microsoft.Storage/storageAccounts/managementPolicies` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/storageAccounts/managementPolicies) |
| `Microsoft.Storage/storageAccounts/managementPolicies` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2023-01-01/storageAccounts/managementPolicies) |
| `Microsoft.Storage/storageAccounts/queueServices` | [2021-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2021-09-01/storageAccounts/queueServices) |
| `Microsoft.Storage/storageAccounts/queueServices/queues` | [2021-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2021-09-01/storageAccounts/queueServices/queues) |
| `Microsoft.Storage/storageAccounts/tableServices` | [2021-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2021-09-01/storageAccounts/tableServices) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "15441426428461937893"
"version": "0.25.3.34343",
"templateHash": "18172078163140627549"
},
"name": "Storage Account Blob Container Immutability Policies",
"description": "This module deploys a Storage Account Blob Container Immutability Policy.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "1429761296615247722"
"version": "0.25.3.34343",
"templateHash": "4692605911774255516"
},
"name": "Storage Account Blob Containers",
"description": "This module deploys a Storage Account Blob Container.",
Expand Down Expand Up @@ -274,8 +274,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "15441426428461937893"
"version": "0.25.3.34343",
"templateHash": "18172078163140627549"
},
"name": "Storage Account Blob Container Immutability Policies",
"description": "This module deploys a Storage Account Blob Container Immutability Policy.",
Expand Down
12 changes: 6 additions & 6 deletions avm/res/storage/storage-account/blob-service/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "6670506366627013721"
"version": "0.25.3.34343",
"templateHash": "1767452448979292347"
},
"name": "Storage Account blob Services",
"description": "This module deploys a Storage Account Blob Service.",
Expand Down Expand Up @@ -371,8 +371,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "1429761296615247722"
"version": "0.25.3.34343",
"templateHash": "4692605911774255516"
},
"name": "Storage Account Blob Containers",
"description": "This module deploys a Storage Account Blob Container.",
Expand Down Expand Up @@ -640,8 +640,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "15441426428461937893"
"version": "0.25.3.34343",
"templateHash": "18172078163140627549"
},
"name": "Storage Account Blob Container Immutability Policies",
"description": "This module deploys a Storage Account Blob Container Immutability Policy.",
Expand Down
2 changes: 1 addition & 1 deletion avm/res/storage/storage-account/file-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This module deploys a Storage Account File Share Service.
| :-- | :-- |
| `Microsoft.Insights/diagnosticSettings` | [2021-05-01-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Insights/2021-05-01-preview/diagnosticSettings) |
| `Microsoft.Storage/storageAccounts/fileServices` | [2021-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2021-09-01/storageAccounts/fileServices) |
| `Microsoft.Storage/storageAccounts/fileServices/shares` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/storageAccounts/fileServices/shares) |
| `Microsoft.Storage/storageAccounts/fileServices/shares` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2023-01-01/storageAccounts/fileServices/shares) |

## Parameters

Expand Down
12 changes: 6 additions & 6 deletions avm/res/storage/storage-account/file-service/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "685043578297461233"
"version": "0.25.3.34343",
"templateHash": "525431657620027128"
},
"name": "Storage Account File Share Services",
"description": "This module deploys a Storage Account File Share Service.",
Expand Down Expand Up @@ -254,8 +254,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "11243515252529303304"
"version": "0.25.3.34343",
"templateHash": "17147893039694736501"
},
"name": "Storage Account File Shares",
"description": "This module deploys a Storage Account File Share.",
Expand Down Expand Up @@ -454,8 +454,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "17643632023108067837"
"version": "0.25.3.34343",
"templateHash": "7361754328987495524"
}
},
"parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This module deploys a Storage Account File Share.

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.Storage/storageAccounts/fileServices/shares` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/storageAccounts/fileServices/shares) |
| `Microsoft.Storage/storageAccounts/fileServices/shares` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2023-01-01/storageAccounts/fileServices/shares) |

## Parameters

Expand Down
8 changes: 4 additions & 4 deletions avm/res/storage/storage-account/file-service/share/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "11243515252529303304"
"version": "0.25.3.34343",
"templateHash": "17147893039694736501"
},
"name": "Storage Account File Shares",
"description": "This module deploys a Storage Account File Share.",
Expand Down Expand Up @@ -205,8 +205,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "17643632023108067837"
"version": "0.25.3.34343",
"templateHash": "7361754328987495524"
}
},
"parameters": {
Expand Down
4 changes: 2 additions & 2 deletions avm/res/storage/storage-account/local-user/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "414567084253124464"
"version": "0.25.3.34343",
"templateHash": "10424013943333306181"
},
"name": "Storage Account Local Users",
"description": "This module deploys a Storage Account Local User, which is used for SFTP authentication.",
Expand Down
50 changes: 25 additions & 25 deletions avm/res/storage/storage-account/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -261,32 +261,33 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
}
dnsEndpointType: !empty(dnsEndpointType) ? dnsEndpointType : null
isLocalUserEnabled: isLocalUserEnabled
encryption: {
keySource: !empty(customerManagedKey) ? 'Microsoft.Keyvault' : 'Microsoft.Storage'
services: {
blob: supportsBlobService ? {
enabled: true
} : null
file: supportsFileService ? {
enabled: true
} : null
table: {
enabled: true
encryption: union({
keySource: !empty(customerManagedKey) ? 'Microsoft.Keyvault' : 'Microsoft.Storage'
services: {
blob: supportsBlobService ? {
enabled: true
} : null
file: supportsFileService ? {
enabled: true
} : null
table: {
enabled: true
}
queue: {
enabled: true
}
}
queue: {
enabled: true
keyvaultproperties: !empty(customerManagedKey) ? {
keyname: customerManagedKey!.keyName
keyvaulturi: cMKKeyVault.properties.vaultUri
keyversion: !empty(customerManagedKey.?keyVersion ?? '') ? customerManagedKey!.keyVersion : last(split(cMKKeyVault::cMKKey.properties.keyUriWithVersion, '/'))
} : null
identity: {
userAssignedIdentity: !empty(customerManagedKey.?userAssignedIdentityResourceId) ? cMKUserAssignedIdentity.id : null
}
}
requireInfrastructureEncryption: kind != 'Storage' ? requireInfrastructureEncryption : null
keyvaultproperties: !empty(customerManagedKey) ? {
keyname: customerManagedKey!.keyName
keyvaulturi: cMKKeyVault.properties.vaultUri
keyversion: !empty(customerManagedKey.?keyVersion ?? '') ? customerManagedKey!.keyVersion : last(split(cMKKeyVault::cMKKey.properties.keyUriWithVersion, '/'))
} : null
identity: {
userAssignedIdentity: !empty(customerManagedKey.?userAssignedIdentityResourceId) ? cMKUserAssignedIdentity.id : null
}
}
}, (requireInfrastructureEncryption ? {
requireInfrastructureEncryption: kind != 'Storage' ? requireInfrastructureEncryption : null
} : {}))
accessTier: kind != 'Storage' ? accessTier : null
sasPolicy: !empty(sasExpirationPeriod) ? {
expirationAction: 'Log'
Expand Down Expand Up @@ -546,7 +547,6 @@ type networkAclsType = {
defaultAction: ('Allow' | 'Deny')
}


type privateEndpointType = {
@description('Optional. The name of the private endpoint.')
name: string?
Expand Down
21 changes: 2 additions & 19 deletions avm/res/storage/storage-account/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.25.3.34343",
"templateHash": "631937264961119905"
"templateHash": "11481386241542947145"
},
"name": "Storage Accounts",
"description": "This module deploys a Storage Account.",
Expand Down Expand Up @@ -887,24 +887,7 @@
},
"dnsEndpointType": "[if(not(empty(parameters('dnsEndpointType'))), parameters('dnsEndpointType'), null())]",
"isLocalUserEnabled": "[parameters('isLocalUserEnabled')]",
"encryption": {
"keySource": "[if(not(empty(parameters('customerManagedKey'))), 'Microsoft.Keyvault', 'Microsoft.Storage')]",
"services": {
"blob": "[if(variables('supportsBlobService'), createObject('enabled', true()), null())]",
"file": "[if(variables('supportsFileService'), createObject('enabled', true()), null())]",
"table": {
"enabled": true
},
"queue": {
"enabled": true
}
},
"requireInfrastructureEncryption": "[if(not(equals(parameters('kind'), 'Storage')), parameters('requireInfrastructureEncryption'), null())]",
"keyvaultproperties": "[if(not(empty(parameters('customerManagedKey'))), createObject('keyname', parameters('customerManagedKey').keyName, 'keyvaulturi', reference('cMKKeyVault').vaultUri, 'keyversion', if(not(empty(coalesce(tryGet(parameters('customerManagedKey'), 'keyVersion'), ''))), parameters('customerManagedKey').keyVersion, last(split(reference('cMKKeyVault::cMKKey').keyUriWithVersion, '/')))), null())]",
"identity": {
"userAssignedIdentity": "[if(not(empty(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'))), extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '//'), '/')[2], split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '////'), '/')[4]), 'Microsoft.ManagedIdentity/userAssignedIdentities', last(split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), 'dummyMsi'), '/'))), null())]"
}
},
"encryption": "[union(createObject('keySource', if(not(empty(parameters('customerManagedKey'))), 'Microsoft.Keyvault', 'Microsoft.Storage'), 'services', createObject('blob', if(variables('supportsBlobService'), createObject('enabled', true()), null()), 'file', if(variables('supportsFileService'), createObject('enabled', true()), null()), 'table', createObject('enabled', true()), 'queue', createObject('enabled', true())), 'keyvaultproperties', if(not(empty(parameters('customerManagedKey'))), createObject('keyname', parameters('customerManagedKey').keyName, 'keyvaulturi', reference('cMKKeyVault').vaultUri, 'keyversion', if(not(empty(coalesce(tryGet(parameters('customerManagedKey'), 'keyVersion'), ''))), parameters('customerManagedKey').keyVersion, last(split(reference('cMKKeyVault::cMKKey').keyUriWithVersion, '/')))), null()), 'identity', createObject('userAssignedIdentity', if(not(empty(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'))), extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '//'), '/')[2], split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '////'), '/')[4]), 'Microsoft.ManagedIdentity/userAssignedIdentities', last(split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), 'dummyMsi'), '/'))), null()))), if(parameters('requireInfrastructureEncryption'), createObject('requireInfrastructureEncryption', if(not(equals(parameters('kind'), 'Storage')), parameters('requireInfrastructureEncryption'), null())), createObject()))]",
"accessTier": "[if(not(equals(parameters('kind'), 'Storage')), parameters('accessTier'), null())]",
"sasPolicy": "[if(not(empty(parameters('sasExpirationPeriod'))), createObject('expirationAction', 'Log', 'sasExpirationPeriod', parameters('sasExpirationPeriod')), null())]",
"supportsHttpsTrafficOnly": "[parameters('supportsHttpsTrafficOnly')]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This module deploys a Storage Account Management Policy.

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.Storage/storageAccounts/managementPolicies` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/storageAccounts/managementPolicies) |
| `Microsoft.Storage/storageAccounts/managementPolicies` | [2023-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2023-01-01/storageAccounts/managementPolicies) |

## Parameters

Expand Down
4 changes: 2 additions & 2 deletions avm/res/storage/storage-account/management-policy/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "17360500138014235250"
"version": "0.25.3.34343",
"templateHash": "3500765950730474634"
},
"name": "Storage Account Management Policies",
"description": "This module deploys a Storage Account Management Policy.",
Expand Down
8 changes: 4 additions & 4 deletions avm/res/storage/storage-account/queue-service/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "9901414791831714811"
"version": "0.25.3.34343",
"templateHash": "4596144758979274883"
},
"name": "Storage Account Queue Services",
"description": "This module deploys a Storage Account Queue Service.",
Expand Down Expand Up @@ -218,8 +218,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "11104056744955032379"
"version": "0.25.3.34343",
"templateHash": "15723904499918946832"
},
"name": "Storage Account Queues",
"description": "This module deploys a Storage Account Queue.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/storage/storage-account/queue-service/queue/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "11104056744955032379"
"version": "0.25.3.34343",
"templateHash": "15723904499918946832"
},
"name": "Storage Account Queues",
"description": "This module deploys a Storage Account Queue.",
Expand Down
8 changes: 4 additions & 4 deletions avm/res/storage/storage-account/table-service/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "4432761872900647010"
"version": "0.25.3.34343",
"templateHash": "11627405660929516603"
},
"name": "Storage Account Table Services",
"description": "This module deploys a Storage Account Table Service.",
Expand Down Expand Up @@ -215,8 +215,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "981180809348713884"
"version": "0.25.3.34343",
"templateHash": "1839032011015561279"
},
"name": "Storage Account Table",
"description": "This module deploys a Storage Account Table.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/storage/storage-account/table-service/table/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "981180809348713884"
"version": "0.25.3.34343",
"templateHash": "1839032011015561279"
},
"name": "Storage Account Table",
"description": "This module deploys a Storage Account Table.",
Expand Down
2 changes: 1 addition & 1 deletion avm/res/storage/storage-account/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"pathFilters": [
"./main.json"
]
}
}

0 comments on commit 6a028e3

Please sign in to comment.