Skip to main content

Azure Policy Definition Module

Terraform module for creating and managing Azure Policy Definitions.

Repository

terraform-azure-policy-definition

Usage

module "policy_definition" {
source = "github.com/Rivia-AI/terraform-azure-policy-definition"

name = "require-tag-environment"
display_name = "Require Environment Tag"
description = "Ensures all resources have an Environment tag"
policy_type = "Custom"
mode = "All"

policy_rule = jsonencode({
if = {
field = "tags['Environment']"
exists = false
}
then = {
effect = "deny"
}
})

parameters = jsonencode({
tagName = {
type = "String"
metadata = {
displayName = "Tag Name"
description = "Name of the tag to require"
}
}
})
}

Requirements

NameVersion
terraform>= 1.6.0
azurerm>= 3.0

Inputs

NameDescriptionTypeDefaultRequired
nameThe name of the policy definitionstringn/ayes
display_nameThe display name of the policy definitionstringn/ayes
descriptionThe description of the policy definitionstring""no
policy_typeThe type of policy definitionstring"Custom"no
modeThe mode of the policy definitionstring"All"no
policy_ruleThe policy rule JSONstringn/ayes
parametersThe parameters JSONstringnullno
metadataThe metadata JSONstringnullno

Outputs

NameDescription
policy_definition_idThe ID of the policy definition
policy_definition_nameThe name of the policy definition

Examples

See the examples directory for more usage examples.

Learn More