Skip to content

Latest commit

 

History

History
87 lines (65 loc) · 3.15 KB

File metadata and controls

87 lines (65 loc) · 3.15 KB

Terraform Template - Azure Event Hubs

Costa Rica

GitHub brown9804

Last updated: 2026-02-17


This template contains Terraform configurations to create an Azure Event Hubs namespace and an Event Hub (optionally with consumer groups).

Note

  • The Resource Group is created via the AzAPI provider (management plane) to keep creation idempotent (ARM PUT) and align with other templates in this repository.
  • Event Hubs namespace names are globally unique. Keeping append_random_suffix = true helps avoid collisions.
image
image

File Descriptions

  • main.tf: Creates the Resource Group, Event Hubs Namespace, Event Hub, and optional consumer groups.
  • variables.tf: Defines the input variables used in the Terraform configuration.
  • provider.tf: Configures the AzureRM + AzAPI providers.
  • terraform.tfvars: Example values for the variables defined in variables.tf.
  • output.tf: Defines outputs such as namespace and Event Hub IDs.

Variables

Variable Name Description Type Example Value
resource_group_name Resource Group name to create/deploy into. string "rg-analytics-dev-EH"
location Azure region for the deployment. string "eastus"
eventhub_namespace_name Base namespace name. If suffix enabled, final is <base>-<suffix>. string "ehns-analytics-dev"
eventhub_name Event Hub name inside the namespace. string "events"
sku Namespace SKU (Basic, Standard, Premium). string "Standard"
capacity Namespace capacity (ignored for Basic). number 1
partition_count Event Hub partitions. number 2
message_retention Retention in days. number 1
consumer_group_names Optional consumer groups to create. list(string) ["cg-default"]
append_random_suffix Append a random suffix to avoid collisions. bool true
random_suffix_length Length of the random suffix when enabled. number 6
tags Tags applied to resources. map(string) { "env": "dev" }

Usage

  1. Authenticate:

    az login
    az account show
    # If needed:
    az account set --subscription "<subscription-id-or-name>"
  2. Initialize:

    terraform init -upgrade
  3. Validate and plan:

    terraform validate
    terraform plan
  4. Apply:

    terraform apply -auto-approve
Total views

Refresh Date: 2026-02-18