Skip to content

Commit

Permalink
add rule for azapi resource
Browse files Browse the repository at this point in the history
  • Loading branch information
lonegunmanb committed Feb 13, 2025
1 parent f266d96 commit bf034a4
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"mock": {
"GRS": {
"resource_changes": [
{
"address": "azapi_resource.res",
"mode": "managed",
"type": "azapi_resource",
"name": "res",
"provider_name": "registry.terraform.io/azure/azapi",
"change": {
"actions": [
"create"
],
"after": {
"body": {
"sku": {
"name": "Standard_GRS"
}
},
"type": "Microsoft.Storage/storageAccounts@2023-05-01"
}
}
}
]
},
"invalid_Standard_LRS": {
"resource_changes": [
{
"address": "azapi_resource.res",
"mode": "managed",
"type": "azapi_resource",
"name": "res",
"provider_name": "registry.terraform.io/azure/azapi",
"change": {
"actions": [
"create"
],
"after": {
"body": {
"sku": {
"name": "Standard_LRS"
}
},
"type": "Microsoft.Storage/storageAccounts@2023-05-01"
}
}
}
]
},
"invalid_Premium_LRS": {
"resource_changes": [
{
"address": "azapi_resource.res",
"mode": "managed",
"type": "azapi_resource",
"name": "res",
"provider_name": "registry.terraform.io/azure/azapi",
"change": {
"actions": [
"create"
],
"after": {
"body": {
"sku": {
"name": "Premium_LRS"
}
},
"type": "Microsoft.Storage/storageAccounts@2023-05-01"
}
}
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package Azure_Proactive_Resiliency_Library_v2.storage_accounts_are_zone_or_region_redundant

import rego.v1

valid_azapi_account_replication_type(resource) if {
not endswith(resource.values.body.sku.name, "LRS")
}

deny_storage_accounts_are_zone_or_region_redundant contains reason if {
resource := data.utils.resource(input, "azapi_resource")[_]
data.utils.is_azure_type(resource.values, "Microsoft.Storage/storageAccounts")
not valid_azapi_account_replication_type(resource)

reason := sprintf("Azure-Proactive-Resiliency-Library-v2: '%s' `azapi_resource` must not have configured `sku.name` to `\"Standard_LRS\"` nor `\"Premium_LRS\"`: https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Storage/storageAccounts/#ensure-that-storage-accounts-are-zone-or-region-redundant", [resource.address])
}

0 comments on commit bf034a4

Please sign in to comment.