Repository: bridgecrewio/checkov

Issue:
Azure Container Registry - Ensure the registry is zone-redundant
**Describe the issue**
It seems that there are no checkov test in order to ensure that Azure Container Registry deployed using Terraform are zone-redunant.

**Examples**

````hcl
resource "azurerm_container_registry" "example" {
  name                = "containerRegistry1"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  sku                 = "Premium"
  zone_redundancy_enabled = true
}
````

**Version (please complete the following information):**
 - N/A
 
**Additional context**

Azure Container Registry supports optional zone redundancy. [Zone redundancy](https://learn.microsoft.com/en-us/azure/availability-zones/az-overview#availability-zones) provides resiliency and high availability to a registry or replication resource (replica) in a specific region.

Source : https://learn.microsoft.com/en-us/azure/container-registry/zone-redundancy



Discussion:

Resolving patch:
diff --git a/checkov/terraform/checks/resource/azure/ACREnableZoneRedundancy.py b/checkov/terraform/checks/resource/azure/ACREnableZoneRedundancy.py
new file mode 100644
--- /dev/null
+++ b/checkov/terraform/checks/resource/azure/ACREnableZoneRedundancy.py
@@ -0,0 +1,37 @@
+from __future__ import annotations
+
+from checkov.common.models.enums import CheckCategories, CheckResult
+from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
+
+from typing import Any
+
+
+class ACREnableZoneRedundancy(BaseResourceCheck):
+
+    def __init__(self) -> None:
+        """
+        Zone redundancy provides resiliency and high availability to
+        a registry or replication resource in a specific region. Supported on Premium.
+        """
+        name = "Ensure Azure Container Registry (ACR) is zone redundant"
+        id = "CKV_AZURE_233"
+        supported_resources = ("azurerm_container_registry",)
+        categories = (CheckCategories.BACKUP_AND_RECOVERY,)
+        super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
+
+    def scan_resource_conf(self, conf: dict[str, list[Any]]) -> CheckResult:
+        # check registry. default=false
+        if conf.get("zone_redundancy_enabled", []) != [True]:
+            return CheckResult.FAILED
+
+        # check each replica. default=false
+        replications = conf.get("georeplications", {})
+        for replica in replications:
+            zone_redundancy_enabled = replica.get('zone_redundancy_enabled', [])
+            if zone_redundancy_enabled != [True]:
+                return CheckResult.FAILED
+
+        return CheckResult.PASSED
+
+
+check = ACREnableZoneRedundancy()


Test patch:
diff --git a/tests/terraform/checks/resource/azure/example_ACREnableZoneRedundancy/main.tf b/tests/terraform/checks/resource/azure/example_ACREnableZoneRedundancy/main.tf
new file mode 100644
--- /dev/null
+++ b/tests/terraform/checks/resource/azure/example_ACREnableZoneRedundancy/main.tf
@@ -0,0 +1,58 @@
+
+resource "azurerm_container_registry" "pass" {
+  name                    = "containerRegistry1"
+  resource_group_name     = azurerm_resource_group.example.name
+  location                = azurerm_resource_group.example.location
+  sku                     = "Premium"
+  zone_redundancy_enabled = true
+}
+
+
+resource "azurerm_container_registry" "pass2" {
+  name                    = "containerRegistry1"
+  resource_group_name     = azurerm_resource_group.example.name
+  location                = azurerm_resource_group.example.location
+  sku                     = "Premium"
+  zone_redundancy_enabled = true
+  georeplications {
+    location                = "East US"
+    zone_redundancy_enabled = true
+  }
+  georeplications {
+    location                = "North Europe"
+    zone_redundancy_enabled = true
+  }
+}
+
+
+resource "azurerm_container_registry" "fail" {
+  name                = "containerRegistry1"
+  resource_group_name = azurerm_resource_group.example.name
+  location            = azurerm_resource_group.example.location
+  sku                 = "Premium"
+}
+
+
+resource "azurerm_container_registry" "fail2" {
+  name                    = "containerRegistry1"
+  resource_group_name     = azurerm_resource_group.example.name
+  location                = azurerm_resource_group.example.location
+  sku                     = "Premium"
+  zone_redundancy_enabled = false
+}
+
+
+resource "azurerm_container_registry" "fail3" {
+  name                    = "containerRegistry1"
+  resource_group_name     = azurerm_resource_group.example.name
+  location                = azurerm_resource_group.example.location
+  sku                     = "Premium"
+  zone_redundancy_enabled = true
+  georeplications {
+    location = "East US"
+  }
+  georeplications {
+    location                = "North Europe"
+    zone_redundancy_enabled = true
+  }
+}
diff --git a/tests/terraform/checks/resource/azure/test_ACREnableZoneRedundancy.py b/tests/terraform/checks/resource/azure/test_ACREnableZoneRedundancy.py
new file mode 100644
--- /dev/null
+++ b/tests/terraform/checks/resource/azure/test_ACREnableZoneRedundancy.py
@@ -0,0 +1,44 @@
+import os
+import unittest
+
+from checkov.runner_filter import RunnerFilter
+from checkov.terraform.runner import Runner
+from checkov.terraform.checks.resource.azure.ACREnableZoneRedundancy import check
+
+
+class TestACREnableZoneRedundancy(unittest.TestCase):
+
+    def test(self):
+        runner = Runner()
+        current_dir = os.path.dirname(os.path.realpath(__file__))
+
+        test_files_dir = os.path.join(current_dir, "example_ACREnableZoneRedundancy")
+        report = runner.run(root_folder=test_files_dir,
+                            runner_filter=RunnerFilter(checks=[check.id]))
+        summary = report.get_summary()
+
+        passing_resources = {
+            'azurerm_container_registry.pass',
+            'azurerm_container_registry.pass2',
+        }
+        failing_resources = {
+            'azurerm_container_registry.fail',
+            'azurerm_container_registry.fail2',
+            'azurerm_container_registry.fail3',
+        }
+        skipped_resources = {}
+
+        passed_check_resources = set([c.resource for c in report.passed_checks])
+        failed_check_resources = set([c.resource for c in report.failed_checks])
+
+        self.assertEqual(summary['passed'], len(passing_resources))
+        self.assertEqual(summary['failed'], len(failing_resources))
+        self.assertEqual(summary['skipped'], len(skipped_resources))
+        self.assertEqual(summary['parsing_errors'], 0)
+
+        self.assertEqual(passing_resources, passed_check_resources)
+        self.assertEqual(failing_resources, failed_check_resources)
+
+
+if __name__ == '__main__':
+    unittest.main()