-
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 microsoft_network_applicationGateways_sku_name rule
- Loading branch information
1 parent
d1ed4b1
commit ccd10bf
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
...iliency-Library-v2/azapi/network/microsoft_network_applicationGateways_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,91 @@ | ||
{ | ||
"mock": { | ||
"Standard_v2": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azapi_resource.gw", | ||
"mode": "managed", | ||
"type": "azapi_resource", | ||
"name": "gw", | ||
"provider_name": "registry.terraform.io/azure/azapi", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"body": { | ||
"properties": { | ||
"sku": { | ||
"capacity": 2, | ||
"name": "Standard_v2", | ||
"tier": "Standard_v2" | ||
} | ||
} | ||
}, | ||
"name": "example-appgateway", | ||
"type": "Microsoft.Network/applicationGateways@2024-03-01" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"WAF_v2": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azapi_resource.gw", | ||
"mode": "managed", | ||
"type": "azapi_resource", | ||
"name": "gw", | ||
"provider_name": "registry.terraform.io/azure/azapi", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"body": { | ||
"properties": { | ||
"sku": { | ||
"capacity": 2, | ||
"name": "WAF_v2", | ||
"tier": "WAF_v2" | ||
} | ||
} | ||
}, | ||
"name": "example-appgateway", | ||
"type": "Microsoft.Network/applicationGateways@2024-03-01" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_basic": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azapi_resource.gw", | ||
"mode": "managed", | ||
"type": "azapi_resource", | ||
"name": "gw", | ||
"provider_name": "registry.terraform.io/azure/azapi", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"after": { | ||
"body": { | ||
"properties": { | ||
"sku": { | ||
"capacity": 2, | ||
"name": "Basic", | ||
"tier": "Basic" | ||
} | ||
} | ||
}, | ||
"name": "example-appgateway", | ||
"type": "Microsoft.Network/applicationGateways@2024-03-01" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...e-Resiliency-Library-v2/azapi/network/microsoft_network_applicationGateways_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,21 @@ | ||
package Azure_Proactive_Resiliency_Library_v2.azurerm_application_gateway | ||
|
||
valid_azapi_sku(resource) { | ||
resource.change.after.body.properties.sku.name == "Standard_v2" | ||
} | ||
|
||
valid_azapi_sku(resource) { | ||
resource.change.after.body.properties.sku.name == "WAF_v2" | ||
} | ||
|
||
deny[reason] { | ||
tfplan := data.utils.tfplan(input) | ||
resource := tfplan.resource_changes[_] | ||
resource.mode == "managed" | ||
resource.type == "azapi_resource" | ||
data.utils.azapi_resource_type_equals(resource.change.after, "Microsoft.Network/applicationGateways") | ||
data.utils.is_create_or_update(resource.change.actions) | ||
not valid_azapi_sku(resource) | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2: '%s' `azapi_resource` must have 'body.properties.sku.name' set to 'Standard_v2' or 'WAF_v2': https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Network/applicationGateways/#migrate-to-application-gateway-v2", [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