-
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
5f2b999
commit 6f73c01
Showing
7 changed files
with
183 additions
and
9 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...-Proactive-Resiliency-Library-v2/azapi/compute/microsoft_compute_disks_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": { | ||
"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.Compute/disks@2024-03-02" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"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.Compute/disks@2024-03-02" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"ultrassd_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": "UltraSSD_LRS" | ||
} | ||
}, | ||
"type": "Microsoft.Compute/disks@2024-03-02" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...Azure-Proactive-Resiliency-Library-v2/azapi/compute/microsoft_compute_disks_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,19 @@ | ||
package Azure_Proactive_Resiliency_Library_v2.mission_critical_virtual_machine_should_use_premium_or_ultra_disks | ||
|
||
import rego.v1 | ||
|
||
valid_azapi_disk_sku_name(resource) if { | ||
startswith(resource.values.body.sku.name, "Premium") | ||
} | ||
|
||
valid_azapi_disk_sku_name(resource) if { | ||
startswith(resource.values.body.sku.name, "Ultra") | ||
} | ||
|
||
deny_mission_critical_virtual_machine_should_use_premium_or_ultra_disks contains reason if { | ||
resource := data.utils.resource(input, "azapi_resource")[_] | ||
data.utils.is_azure_type(resource.values, "Microsoft.Compute/disks") | ||
not valid_azapi_disk_sku_name(resource) | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2: '%s' `azapi_resource` must have configured `sku.name` to use Premium or Ultra type: https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#mission-critical-workloads-should-consider-using-premium-or-ultra-disks", [resource.address]) | ||
} |
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
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
61 changes: 61 additions & 0 deletions
61
...Resiliency-Library-v2/azurerm/compute/azurerm_managed_disk_storage_account_type.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,61 @@ | ||
{ | ||
"mock": { | ||
"invalid_Standard_LRS": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_managed_disk.example", | ||
"mode": "managed", | ||
"type": "azurerm_managed_disk", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"storage_account_type": "Standard_LRS" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"premium_lrs": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_managed_disk.example", | ||
"mode": "managed", | ||
"type": "azurerm_managed_disk", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"storage_account_type": "Premium_LRS" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"ultrassd_lrs": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_managed_disk.example", | ||
"mode": "managed", | ||
"type": "azurerm_managed_disk", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"storage_account_type": "UltraSSD_LRS" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...tive-Resiliency-Library-v2/azurerm/compute/azurerm_managed_disk_storage_account_type.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,18 @@ | ||
package Azure_Proactive_Resiliency_Library_v2.mission_critical_virtual_machine_should_use_premium_or_ultra_disks | ||
|
||
import rego.v1 | ||
|
||
valid_azurerm_managed_disk_storage_account_type(resource) if { | ||
startswith(resource.values.storage_account_type, "Premium") | ||
} | ||
|
||
valid_azurerm_managed_disk_storage_account_type(resource) if { | ||
startswith(resource.values.storage_account_type, "Ultra") | ||
} | ||
|
||
deny_mission_critical_virtual_machine_should_use_premium_or_ultra_disks contains reason if { | ||
resource := data.utils.resource(input, "azurerm_managed_disk")[_] | ||
not valid_azurerm_managed_disk_storage_account_type(resource) | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2: '%s' `azurerm_managed_disk` must have configured `storage_account_type` to use Premium or Ultra type: https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#mission-critical-workloads-should-consider-using-premium-or-ultra-disks", [resource.address]) | ||
} |
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