Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions modules/azure-policy-definitions/.terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
formatter: "markdown"

version: ""

header-from: docs/header.md
footer-from: docs/footer.md

recursive:
enabled: false
path: modules
include-main: true

sections:
hide: []
show: []

content: ""

output:
file: "README.MD"
mode: inject
template: |-
<!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->

output-values:
enabled: false
from: ""

sort:
enabled: true
by: name

settings:
anchor: true
color: true
default: true
description: false
escape: true
hide-empty: false
html: true
indent: 2
lockfile: true
read-comments: true
required: true
sensitive: true
type: true
161 changes: 161 additions & 0 deletions modules/azure-policy-definitions/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,164 @@ policies = [
}
]
```

<!-- BEGIN_TF_DOCS -->
# Azure Policy Definitions Terraform Module

## Overview

This Terraform module allows you to create custom Azure Policy Definitions, supporting all policy rule, metadata, and parameter options.

## Main features
- Create custom policy definitions with flexible rules and metadata.
- Support for all policy definition fields, including parameters and management group assignment.
- Realistic configuration example.

## Complete usage example

### YAML
```yaml
values:
policies:
- name: "example-policy"
policy_type: "Custom"
mode: "All"
display_name: "Example Policy"
description: "A sample policy to audit location."
policy_rule: |
{
"if": {
"field": "location",
"equals": "westeurope"
},
"then": {
"effect": "audit"
}
}
- name: "example-policy2"
policy_type: "Custom"
mode: "All"
display_name: "Example Policy 2"
description: "A sample policy to audit location."
policy_rule: |
{
"if": {
"field": "location",
"equals": "westeurope"
},
"then": {
"effect": "audit"
}
}
```

### HCL
```hcl
policies = [
{
name = "example-policy"
policy_type = "Custom"
mode = "All"
display_name = "Example Policy"
description = "A sample policy to audit location."
policy_rule = jsonencode({
"if" = {
"field" = "location"
"equals" = "westeurope"
}
"then" = {
"effect" = "audit"
}
})
metadata = "{}"
parameters = "{}"
},
{
name = "example-policy2"
policy_type = "Custom"
mode = "All"
display_name = "Example Policy 2"
description = "A sample policy to audit location."
policy_rule = jsonencode({
"if" = {
"field" = "location"
"equals" = "westeurope"
}
"then" = {
"effect" = "audit"
}
})
}
]
```

## Notes
- You can define any custom policy rule, metadata, and parameters.
- Assign policies to management groups if needed.
- Use the `policies` variable to define all policy details.

## File structure

```
.
├── main.tf
├── variables.tf
├── outputs.tf
├── README.MD
├── CHANGELOG.md
└── docs/
├── header.md
└── footer.md
```

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.7.0 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 4.22.0 |
Comment on lines +225 to +228
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The markdown tables in the generated README section use a double leading pipe (||), which renders incorrectly (introduces an empty first column / malformed table). This should be single-pipe table syntax (e.g., | Name | Version |). Regenerating with terraform-docs after adjusting the template/config (or correcting the committed output) should fix this across Requirements/Providers/Inputs/Outputs.

Copilot uses AI. Check for mistakes.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >= 4.22.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [azurerm_policy_definition.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/policy_definition) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_policies"></a> [policies](#input\_policies) | List of objects containing all the variables for the policy definitions. | <pre>list(object({<br/> name = string<br/> policy_type = string<br/> mode = string<br/> display_name = string<br/> description = optional(string)<br/> management_group_id = optional(string)<br/> policy_rule = optional(string)<br/> metadata = optional(string)<br/> parameters = optional(string)<br/> }))</pre> | `[]` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_policy_definition_ids"></a> [policy\_definition\_ids](#output\_policy\_definition\_ids) | List of all Azure Policy definition IDs |
| <a name="output_policy_definition_names"></a> [policy\_definition\_names](#output\_policy\_definition\_names) | List of all Azure Policy definition names |

## Examples

For detailed examples, refer to the [module examples](https://github.com/prefapp/tfm/tree/main/modules/azure-policy-definitions/_examples):

- [basic](https://github.com/prefapp/tfm/tree/main/modules/azure-policy-definitions/_examples/basic) - Custom policy definitions for common governance scenarios.

## Resources and support

- [Official Azure Policy documentation](https://learn.microsoft.com/en-us/azure/governance/policy/overview)
- [Terraform reference for azurerm\_policy\_definition](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/policy_definition)

## Support

For issues, questions, or contributions related to this module, please visit the [repository's issue tracker](https://github.com/prefapp/tfm/issues).
<!-- END_TF_DOCS -->
24 changes: 24 additions & 0 deletions modules/azure-policy-definitions/_examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module "azure_policy_definitions" {
source = "../../"

policies = [
{
name = "example-policy"
policy_type = "Custom"
mode = "All"
display_name = "Example Policy"
description = "A sample policy to audit location."
policy_rule = jsonencode({
"if" = {
"field" = "location"
"equals" = "westeurope"
}
"then" = {
"effect" = "audit"
}
})
metadata = "{}"
parameters = "{}"
}
]
}
18 changes: 18 additions & 0 deletions modules/azure-policy-definitions/_examples/basic/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
policies:
- name: example-policy
policy_type: Custom
mode: All
display_name: Example Policy
description: A sample policy to audit location.
policy_rule: |
{
"if": {
"field": "location",
"equals": "westeurope"
},
"then": {
"effect": "audit"
}
}
metadata: "{}"
parameters: "{}"
14 changes: 14 additions & 0 deletions modules/azure-policy-definitions/docs/footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Examples

For detailed examples, refer to the [module examples](https://github.com/prefapp/tfm/tree/main/modules/azure-policy-definitions/_examples):

- [basic](https://github.com/prefapp/tfm/tree/main/modules/azure-policy-definitions/_examples/basic) - Custom policy definitions for common governance scenarios.

## Resources and support

- [Official Azure Policy documentation](https://learn.microsoft.com/en-us/azure/governance/policy/overview)
- [Terraform reference for azurerm_policy_definition](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/policy_definition)

## Support

For issues, questions, or contributions related to this module, please visit the [repository's issue tracker](https://github.com/prefapp/tfm/issues).
107 changes: 107 additions & 0 deletions modules/azure-policy-definitions/docs/header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Azure Policy Definitions Terraform Module

## Overview

This Terraform module allows you to create custom Azure Policy Definitions, supporting all policy rule, metadata, and parameter options.

## Main features
- Create custom policy definitions with flexible rules and metadata.
- Support for all policy definition fields, including parameters and management group assignment.
- Realistic configuration example.

## Complete usage example

### YAML
```yaml
values:
policies:
- name: "example-policy"
policy_type: "Custom"
mode: "All"
display_name: "Example Policy"
description: "A sample policy to audit location."
policy_rule: |
{
"if": {
"field": "location",
"equals": "westeurope"
},
"then": {
"effect": "audit"
}
}
- name: "example-policy2"
policy_type: "Custom"
mode: "All"
display_name: "Example Policy 2"
description: "A sample policy to audit location."
policy_rule: |
{
"if": {
"field": "location",
"equals": "westeurope"
},
"then": {
"effect": "audit"
}
}
Comment on lines +16 to +47
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The YAML example is wrapped under values: but the repository example file (_examples/basic/values.yaml) uses policies: at the root. This inconsistency can confuse users copying the snippet. Consider updating the header example to match the real example structure (root policies:), or update the _examples/basic/values.yaml to include the values: wrapper—whichever reflects the actual consumption pattern.

Suggested change
values:
policies:
- name: "example-policy"
policy_type: "Custom"
mode: "All"
display_name: "Example Policy"
description: "A sample policy to audit location."
policy_rule: |
{
"if": {
"field": "location",
"equals": "westeurope"
},
"then": {
"effect": "audit"
}
}
- name: "example-policy2"
policy_type: "Custom"
mode: "All"
display_name: "Example Policy 2"
description: "A sample policy to audit location."
policy_rule: |
{
"if": {
"field": "location",
"equals": "westeurope"
},
"then": {
"effect": "audit"
}
}
policies:
- name: "example-policy"
policy_type: "Custom"
mode: "All"
display_name: "Example Policy"
description: "A sample policy to audit location."
policy_rule: |
{
"if": {
"field": "location",
"equals": "westeurope"
},
"then": {
"effect": "audit"
}
}
- name: "example-policy2"
policy_type: "Custom"
mode: "All"
display_name: "Example Policy 2"
description: "A sample policy to audit location."
policy_rule: |
{
"if": {
"field": "location",
"equals": "westeurope"
},
"then": {
"effect": "audit"
}
}

Copilot uses AI. Check for mistakes.
```

### HCL
```hcl
policies = [
{
name = "example-policy"
policy_type = "Custom"
mode = "All"
display_name = "Example Policy"
description = "A sample policy to audit location."
policy_rule = jsonencode({
"if" = {
"field" = "location"
"equals" = "westeurope"
}
"then" = {
"effect" = "audit"
}
})
metadata = "{}"
parameters = "{}"
},
{
name = "example-policy2"
policy_type = "Custom"
mode = "All"
display_name = "Example Policy 2"
description = "A sample policy to audit location."
policy_rule = jsonencode({
"if" = {
"field" = "location"
"equals" = "westeurope"
}
"then" = {
"effect" = "audit"
}
})
}
]
```

## Notes
- You can define any custom policy rule, metadata, and parameters.
- Assign policies to management groups if needed.
- Use the `policies` variable to define all policy details.

## File structure

```
.
├── main.tf
├── variables.tf
├── outputs.tf
├── README.MD
├── CHANGELOG.md
└── docs/
├── header.md
└── footer.md
```