Skip to main content

Azure Policy Assignment Module

Terraform module for assigning Azure Policies to scopes.

Repository

terraform-azure-policy-assignment

Usage

module "policy_assignment" {
source = "github.com/Rivia-AI/terraform-azure-policy-assignment"

name = "require-tag-environment"
policy_definition_id = "/providers/Microsoft.Authorization/policyDefinitions/..."
scope = "/subscriptions/your-subscription-id"
display_name = "Require Environment Tag"
description = "Assigns policy to require Environment tag"

parameters = {
tagName = "Environment"
}

non_compliance_messages {
message = "Resource must have Environment tag"
}
}

Requirements

NameVersion
terraform>= 1.6.0
azurerm>= 3.0

Inputs

NameDescriptionTypeDefaultRequired
nameThe name of the policy assignmentstringn/ayes
policy_definition_idThe ID of the policy definitionstringn/ayes
scopeThe scope at which the policy is assignedstringn/ayes
display_nameThe display name of the policy assignmentstringnullno
descriptionThe description of the policy assignmentstringnullno
parametersThe parameters for the policy assignmentmap(any){}no
non_compliance_messagesNon-compliance messageslist(object)[]no
locationThe location for the policy assignmentstringnullno
identityManaged identity configurationobjectnullno

Outputs

NameDescription
policy_assignment_idThe ID of the policy assignment
policy_assignment_nameThe name of the policy assignment

Examples

See the examples directory for more usage examples.

Learn More