-
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.
add new rule migrate_vm_using_availability_sets_to_vmss_flex
- Loading branch information
1 parent
b1a952a
commit 0d1452d
Showing
7 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...y-v2/azapi/compute/microsoft_compute_virtualMachines_properties_availabilitySet.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,53 @@ | ||
{ | ||
"mock": { | ||
"invalid_case": { | ||
"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": { | ||
"properties": { | ||
"availabilitySet": { | ||
"id": "/subscriptions/xxx/resourceGroups/vmss-neat/providers/Microsoft.Compute/availabilitySets/acctestavset" | ||
} | ||
} | ||
}, | ||
"type": "Microsoft.Compute/virtualMachines@2024-07-01" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"valid_case": { | ||
"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": { | ||
"properties": { | ||
} | ||
}, | ||
"type": "Microsoft.Compute/virtualMachines@2024-07-01" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ibrary-v2/azapi/compute/microsoft_compute_virtualMachines_properties_availabilitySet.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.migrate_vm_using_availability_sets_to_vmss_flex | ||
|
||
import rego.v1 | ||
|
||
valid_azapi_virtual_machine_properties_availabilitySet(resource) if { | ||
not resource.values.body.properties.availabilitySet | ||
} | ||
|
||
deny_migrate_vm_using_availability_sets_to_vmss_flex contains reason if { | ||
resource := data.utils.resource(input, "azapi_resource")[_] | ||
data.utils.is_azure_type(resource.values, "Microsoft.Compute/virtualMachines") | ||
not valid_azapi_virtual_machine_properties_availabilitySet(resource) | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2: '%s' `azapi_resource` must not define `properties.availabilitySet`: https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#migrate-vms-using-availability-sets-to-vmss-flex", [resource.address]) | ||
} |
41 changes: 41 additions & 0 deletions
41
...cy-Library-v2/azurerm/compute/azurerm_linux_virtual_machine_availability_set_id.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,41 @@ | ||
{ | ||
"mock": { | ||
"default": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_linux_virtual_machine.example", | ||
"mode": "managed", | ||
"type": "azurerm_linux_virtual_machine", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_case": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_linux_virtual_machine.example", | ||
"mode": "managed", | ||
"type": "azurerm_linux_virtual_machine", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"availability_set_id": "/subscriptions/xxx/resourceGroups/vmss-neat/providers/Microsoft.Compute/availabilitySets/acctestavset" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...iliency-Library-v2/azurerm/compute/azurerm_linux_virtual_machine_availability_set_id.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,10 @@ | ||
package Azure_Proactive_Resiliency_Library_v2.migrate_vm_using_availability_sets_to_vmss_flex | ||
|
||
import rego.v1 | ||
|
||
deny_migrate_vm_using_availability_sets_to_vmss_flex contains reason if { | ||
resource := data.utils.resource(input, "azurerm_linux_virtual_machine")[_] | ||
resource.values.availability_set_id | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2: '%s' `azurerm_linux_virtual_machine` must not define `availability_set_id`: https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#migrate-vms-using-availability-sets-to-vmss-flex", [resource.address]) | ||
} |
41 changes: 41 additions & 0 deletions
41
...-Library-v2/azurerm/compute/azurerm_windows_virtual_machine_availability_set_id.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,41 @@ | ||
{ | ||
"mock": { | ||
"default": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_windows_virtual_machine.example", | ||
"mode": "managed", | ||
"type": "azurerm_windows_virtual_machine", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_case": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_windows_virtual_machine.example", | ||
"mode": "managed", | ||
"type": "azurerm_windows_virtual_machine", | ||
"name": "example", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"availability_set_id": "/subscriptions/xxx/resourceGroups/vmss-neat/providers/Microsoft.Compute/availabilitySets/acctestavset" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...iency-Library-v2/azurerm/compute/azurerm_windows_virtual_machine_availability_set_id.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,10 @@ | ||
package Azure_Proactive_Resiliency_Library_v2.migrate_vm_using_availability_sets_to_vmss_flex | ||
|
||
import rego.v1 | ||
|
||
deny_migrate_vm_using_availability_sets_to_vmss_flex contains reason if { | ||
resource := data.utils.resource(input, "azurerm_windows_virtual_machine")[_] | ||
resource.values.availability_set_id | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2: '%s' `azurerm_linux_virtual_machine` must not define `availability_set_id`: https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Compute/virtualMachines/#migrate-vms-using-availability-sets-to-vmss-flex", [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