You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The policy example below enforces Azure resources to be in “UK South” or “UK West” only. If resources are found elsewhere it will be reported by Terrascan.
# azure_region_policy.regopackage main
import input.tfplan as tfplan
default allow =false
allowed_regions = ["UK South", "UK West"]
# Iterate over all Azure resources in the Terraform plan.
azure_resources[resource_name] {
resource_name = input.tfplan.resource_changes[_].address
input.tfplan.resource_changes[_].type =="azurerm_resource"
}
# Check if the region of each Azure resource is allowed.
allow {
resource_name
resource_config := input.tfplan.resource_changes[resource_name].change.after
resource_config.location == allowed_region
allowed_region = allowed_regions[_]
}
rule.json
{
"rules": {
"azure_region_policy": {
"severity": "HIGH",
"message": "Azure resources should be deployed in 'UK South' or 'UK West' regions.",
"rules_file": "azure_region_policy.rego"
}
}
}
Execution:
$ terrascan scan -rules /path/to/rule.json
The text was updated successfully, but these errors were encountered:
https://runterrascan.io/
Scannable Resources
Installation
CLI
Docker
Custom Policies
Via Open Policy Agent(OPA).
pkg/policies/opa/rego
rule.json
controls what is applied / severity levelsExample (source)
The policy example below enforces Azure resources to be in “UK South” or “UK West” only. If resources are found elsewhere it will be reported by Terrascan.
rule.json
Execution:
The text was updated successfully, but these errors were encountered: