Skip to content
Draft
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-event-hub/.terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
formatter: "markdown" # this is required

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
145 changes: 100 additions & 45 deletions modules/azure-event-hub/README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,27 @@
## Requirements
<!-- BEGIN_TF_DOCS -->
# Azure Event Hub Terraform Module

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.7.0 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 4.51.0 |

## Providers
## Overview

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


## Resources
This Terraform module allows you to create and manage a complete Azure Event Hub environment, including:
- Namespace, Event Hubs, authorization rules, and consumer groups.
- Integration with Event Grid System Topics and subscriptions.
- Advanced network, security, and scalability configuration.
- Flexible tagging and tag inheritance from the Resource Group.

| Name | Type |
|------|------|
| [azurerm_eventgrid_system_topic.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventgrid_system_topic) | resource |
| [azurerm_eventgrid_system_topic_event_subscription.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventgrid_system_topic_event_subscription) | resource |
| [azurerm_eventhub.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub) | resource |
| [azurerm_eventhub_authorization_rule.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub_authorization_rule) | resource |
| [azurerm_eventhub_consumer_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub_consumer_group) | resource |
| [azurerm_eventhub_namespace.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub_namespace) | resource |
| [azurerm_role_assignment.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
| [azurerm_resource_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source |
## Main features
- Create namespaces and multiple Event Hubs with custom configuration.
- Support for authorization rules, consumer groups, and event subscriptions.
- Integration with Event Grid System Topics.
- Network rules configuration (IP, VNet, public access, etc).

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_eventhub"></a> [eventhub](#input\_eventhub) | n/a | <pre>map(object({<br/> name = string<br/> partition_count = number<br/> message_retention = number<br/> consumer_group_names = list(string)<br/> auth_rules = list(object({<br/> name = string<br/> listen = bool<br/> send = bool<br/> manage = bool<br/> }))<br/> event_subscription = optional(object({<br/> name = string<br/> included_event_types = list(string)<br/> retry_ttl = number<br/> max_attempts = number<br/> }))<br/> system_topic_name = optional(string)<br/> }))</pre> | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | n/a | <pre>object({<br/> name = string<br/> location = string<br/> resource_group_name = string<br/> sku = string<br/> capacity = number<br/> auto_inflate_enabled = bool<br/> identity_type = string<br/> ruleset = object({<br/> default_action = string<br/> public_network_access_enabled = bool<br/> trusted_service_access_enabled = bool<br/> virtual_network_rules = optional(list(object({<br/> subnet_id = string<br/> ignore_missing_virtual_network_service_endpoint = optional(bool)<br/> })), [])<br/> ip_rules = optional(list(object({<br/> ip_mask = string<br/> action = string<br/> })), [])<br/> })<br/> })</pre> | n/a | yes |
| <a name="input_system_topic"></a> [system\_topic](#input\_system\_topic) | n/a | <pre>map(object({<br/> name = string<br/> location = string<br/> topic_type = string<br/> source_resource_id = string<br/> }))</pre> | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to apply to resources | `map(string)` | `{}` | no |
| <a name="input_tags_from_rg"></a> [tags\_from\_rg](#input\_tags\_from\_rg) | Use resource group tags as base for module tags | `bool` | `false` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_eventhub_id"></a> [eventhub\_id](#output\_eventhub\_id) | n/a |
| <a name="output_eventhub_namespace_id"></a> [eventhub\_namespace\_id](#output\_eventhub\_namespace\_id) | Outputs |


## Example of Usage
## Complete usage example

```yaml
values:
tags_from_rg: true
tags:
extra_tag: "example"

namespace:
name: "example-namespace"
location: "westeurope"
Expand All @@ -68,14 +39,12 @@ values:
action: "Allow"
- ip_mask: "10.0.0.2"
action: "Allow"

system_topic:
topic-events:
name: "topic-events"
location: "global"
topic_type: "Microsoft.Resources.Subscriptions"
source_resource_id: "/subscriptions/00000000-0000-0000-0000-000000000000"

eventhub:
events-hub:
name: "events-hub"
Expand Down Expand Up @@ -117,3 +86,89 @@ values:
send: true
manage: false
```

## Notes
- In each `eventhub` entry, `system_topic_name` must be the **map key** of the linked entry in `system_topic` (e.g. `topic-events`), not the topic's `name` attribute.
- In HCL, map keys that contain hyphens (e.g. `example-topic`, `example-hub`) must be quoted: `"example-topic" = { ... }`.

## 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.51.0 |

## Providers

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

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [azurerm_eventgrid_system_topic.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventgrid_system_topic) | resource |
| [azurerm_eventgrid_system_topic_event_subscription.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventgrid_system_topic_event_subscription) | resource |
| [azurerm_eventhub.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub) | resource |
| [azurerm_eventhub_authorization_rule.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub_authorization_rule) | resource |
| [azurerm_eventhub_consumer_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub_consumer_group) | resource |
| [azurerm_eventhub_namespace.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub_namespace) | resource |
| [azurerm_role_assignment.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
| [azurerm_resource_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_eventhub"></a> [eventhub](#input\_eventhub) | n/a | <pre>map(object({<br/> name = string<br/> partition_count = number<br/> message_retention = number<br/> consumer_group_names = list(string)<br/> auth_rules = list(object({<br/> name = string<br/> listen = bool<br/> send = bool<br/> manage = bool<br/> }))<br/> event_subscription = optional(object({<br/> name = string<br/> included_event_types = list(string)<br/> retry_ttl = number<br/> max_attempts = number<br/> }))<br/> system_topic_name = optional(string)<br/> }))</pre> | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | n/a | <pre>object({<br/> name = string<br/> location = string<br/> resource_group_name = string<br/> sku = string<br/> capacity = number<br/> auto_inflate_enabled = bool<br/> identity_type = string<br/> ruleset = object({<br/> default_action = string<br/> public_network_access_enabled = bool<br/> trusted_service_access_enabled = bool<br/> virtual_network_rules = optional(list(object({<br/> subnet_id = string<br/> ignore_missing_virtual_network_service_endpoint = optional(bool)<br/> })), [])<br/> ip_rules = optional(list(object({<br/> ip_mask = string<br/> action = string<br/> })), [])<br/> })<br/> })</pre> | n/a | yes |
| <a name="input_system_topic"></a> [system\_topic](#input\_system\_topic) | n/a | <pre>map(object({<br/> name = string<br/> location = string<br/> topic_type = string<br/> source_resource_id = string<br/> }))</pre> | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to apply to resources | `map(string)` | `{}` | no |
| <a name="input_tags_from_rg"></a> [tags\_from\_rg](#input\_tags\_from\_rg) | Use resource group tags as base for module tags | `bool` | `false` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_eventhub_id"></a> [eventhub\_id](#output\_eventhub\_id) | n/a |
| <a name="output_eventhub_namespace_id"></a> [eventhub\_namespace\_id](#output\_eventhub\_namespace\_id) | Outputs |

---

## Examples

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

- [basic](https://github.com/prefapp/tfm/tree/main/modules/azure-event-hub/_examples/basic) - Event Hub namespace with a basic event hub and optional system topic integration.

## Additional resources

- [Azure Event Hubs](https://learn.microsoft.com/en-us/azure/event-hubs/)
- [Terraform AzureRM Provider - azurerm\_eventhub](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub)
- [Terraform AzureRM Provider - azurerm\_eventhub\_namespace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub_namespace)
- [Terraform AzureRM Provider - azurerm\_eventgrid\_system\_topic](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventgrid_system_topic)
- [Official Terraform documentation](https://www.terraform.io/docs)

## Support

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

namespace = {
name = "example-namespace"
location = "westeurope"
resource_group_name = "example-rg"
sku = "Standard"
capacity = 1
auto_inflate_enabled = false
identity_type = "SystemAssigned"
ruleset = {
default_action = "Allow"
public_network_access_enabled = true
trusted_service_access_enabled = true
virtual_network_rules = []
ip_rules = []
}
}

system_topic = {
"example-topic" = {
name = "example-system-topic"
location = "westeurope"
topic_type = "Microsoft.EventHub.namespaces"
source_resource_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.EventHub/namespaces/example-namespace"
}
}

eventhub = {
"example-hub" = {
name = "example-eventhub"
partition_count = 2
message_retention = 7
consumer_group_names = ["$Default"]
auth_rules = [
{
name = "listen"
listen = true
send = false
manage = false
}
]
event_subscription = null
system_topic_name = "example-topic"
}
}

tags_from_rg = false
tags = {
environment = "dev"
}
}
40 changes: 40 additions & 0 deletions modules/azure-event-hub/_examples/basic/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace:
name: example-namespace
location: westeurope
resource_group_name: example-rg
sku: Standard
capacity: 1
auto_inflate_enabled: false
identity_type: SystemAssigned
ruleset:
default_action: Allow
public_network_access_enabled: true
trusted_service_access_enabled: true
virtual_network_rules: []
ip_rules: []

system_topic:
example-topic:
name: example-system-topic
location: westeurope
topic_type: Microsoft.EventHub.namespaces
source_resource_id: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.EventHub/namespaces/example-namespace
Comment on lines +16 to +21
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 docs in README/header use system_topic_name as the map key selector (e.g., topic-events). In this example, system_topic_name is set to the system topic’s name value (example-system-topic) rather than the map key (example-topic). Align this example with the documented pattern (either change system_topic_name to example-topic, or update docs/module semantics if system_topic_name is intended to be the actual system topic name).

Copilot uses AI. Check for mistakes.

eventhub:
example-hub:
name: example-eventhub
partition_count: 2
message_retention: 7
consumer_group_names:
- $Default
auth_rules:
- name: listen
listen: true
send: false
manage: false
event_subscription: null
system_topic_name: example-topic

tags_from_rg: false
tags:
environment: dev
19 changes: 19 additions & 0 deletions modules/azure-event-hub/docs/footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

## Examples

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

- [basic](https://github.com/prefapp/tfm/tree/main/modules/azure-event-hub/_examples/basic) - Event Hub namespace with a basic event hub and optional system topic integration.

## Additional resources

- [Azure Event Hubs](https://learn.microsoft.com/en-us/azure/event-hubs/)
- [Terraform AzureRM Provider - azurerm_eventhub](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub)
- [Terraform AzureRM Provider - azurerm_eventhub_namespace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventhub_namespace)
- [Terraform AzureRM Provider - azurerm_eventgrid_system_topic](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventgrid_system_topic)
- [Official Terraform documentation](https://www.terraform.io/docs)

## Support

For issues, questions, or contributions related to this module, please visit the repository’s issue tracker: [https://github.com/prefapp/tfm/issues](https://github.com/prefapp/tfm/issues)
Loading