-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f266d96
commit bf034a4
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...-Resiliency-Library-v2/azapi/storage/microsoft_storage_storageAccounts_sku_name.mock.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,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" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ctive-Resiliency-Library-v2/azapi/storage/microsoft_storage_storageAccounts_sku_name.rego
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,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]) | ||
} |