-
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 azurerm_application_gateway_zones policy
- Loading branch information
1 parent
9b5a192
commit d1ed4b1
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...oactive-Resiliency-Library-v2/azurerm/network/azurerm_application_gateway_zones.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,69 @@ | ||
{ | ||
"mock": { | ||
"default": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_application_gateway.network", | ||
"mode": "managed", | ||
"type": "azurerm_application_gateway", | ||
"name": "network", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": { | ||
"resource_group_name": "example-resources", | ||
"zones": [ | ||
1, | ||
2 | ||
] | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_no_zones": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_application_gateway.network", | ||
"mode": "managed", | ||
"type": "azurerm_application_gateway", | ||
"name": "network", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": { | ||
"resource_group_name": "example-resources" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"invalid_no_enough_zones": { | ||
"resource_changes": [ | ||
{ | ||
"address": "azurerm_application_gateway.network", | ||
"mode": "managed", | ||
"type": "azurerm_application_gateway", | ||
"name": "network", | ||
"provider_name": "registry.terraform.io/hashicorp/azurerm", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": { | ||
"resource_group_name": "example-resources", | ||
"zones": [1] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...re-Proactive-Resiliency-Library-v2/azurerm/network/azurerm_application_gateway_zones.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,17 @@ | ||
package Azure_Proactive_Resiliency_Library_v2.azurerm_application_gateway | ||
|
||
valid_zones(after) { | ||
after.zones | ||
count(after.zones) >= 2 | ||
} | ||
|
||
deny[reason] { | ||
tfplan := data.utils.tfplan(input) | ||
resource := tfplan.resource_changes[_] | ||
resource.mode == "managed" | ||
resource.type == "azurerm_application_gateway" | ||
data.utils.is_create_or_update(resource.change.actions) | ||
not valid_zones(resource.change.after) | ||
|
||
reason := sprintf("Azure-Proactive-Resiliency-Library-v2: '%s' `azurerm_application_gateway` must have configured to use at least 2 Availability Zones: https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Network/applicationGateways/#deploy-application-gateway-in-a-zone-redundant-configuration", [resource.address]) | ||
} |