feat(query): implements "Beta - Storage Account Without CMK" #7874
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.








Reason for Proposed Changes
Currently there is no query to ensure a "azurerm_storage_account" resource has CMK encryption enabled.
Quoting CIS_Microsoft_Azure_Foundations_Benchmark_v5.0.0 page 203: "
By default in Azure, data at rest tends to be encrypted using Microsoft-managed keys. If your organization wants to control and manage encryption keys for compliance and defense-in-depth, customer-managed keys can be established. Configuring the storage account with the activity log export container to use CMKs provides additional confidentiality controls on log data, as a given user must have read permission on the corresponding storage account and must be granted decrypt permission by the CMK. While it is possible to automate the assessment of this recommendation, the assessment status for this recommendation remains 'Manual' due to ideally limited scope. The scope of application—which workloads CMK is applied to—should be carefully considered to account for organizational capacity and targeted to workloads with specific need for CMK."Additionally the "Audit from Azure CLI" section of the CIS Benchmark shows that not all "azurerm_storage_account" resources are to be flagged, only the ones associated with a "azurerm_monitor_diagnostic_setting" should be targeted.
To enable CMK encryption for a storage account there are 2 possibilities:
Proposed Changes
azurerm_storage_account" resource that is associated with a "azurerm_monitor_diagnostic_setting" resource, if it does not set the "customer_managed_key" field and has no association with any "azurerm_storage_account_customer_managed_key" resource within the same project.I submit this contribution under the Apache-2.0 license.