### Terraform Module Source from Registry Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/AGENTS.md Example of how to reference an AVM module from the Terraform Registry. Replace placeholders with actual module details. ```terraform source = "https://registry.terraform.io/modules/Azure/{module}/azurerm/latest" ``` -------------------------------- ### Terraform Versions API for Module Versions Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/AGENTS.md Example of constructing a URL to query the Terraform Versions API for a specific module. This can be used to programmatically check available versions. ```terraform source = "https://registry.terraform.io/v1/modules/Azure/{module}/[azurerm|azure]/versions" ``` -------------------------------- ### Terraform Module Source from GitHub Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/AGENTS.md Example of how to reference an AVM module directly from GitHub. This is useful for development or when a module is not yet published to the registry. ```terraform source = "https://github.com/Azure/terraform-azurerm-avm-{type}-{service}-{resource}" ``` -------------------------------- ### Default Terraform Configuration for Event Hubs Module Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/examples/eventhub/README.md This configuration deploys the Event Hubs module in its simplest form. It sets up the required Terraform version, providers, and a naming module for CAF compliant resource names. It also defines a resource group and configures the Event Hubs module with basic settings. ```hcl terraform { required_version = ">= 1.3.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = "~> 4.0" } } } provider "azurerm" { features {} } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.3.0" } # This is required for resource modules resource "azurerm_resource_group" "this" { location = "australiaeast" name = module.naming.resource_group.name_unique } locals { event_hubs = { my_event_hub = { namespace_name = module.event_hub.resource.id partition_count = 1 message_retention = 7 resource_group_name = module.event_hub.resource.name } } } module "event_hub" { source = "../../" location = azurerm_resource_group.this.location name = module.naming.eventhub_namespace.name_unique resource_group_name = azurerm_resource_group.this.name # source = "Azure/avm--/azurerm" # ... enable_telemetry = var.enable_telemetry event_hubs = local.event_hubs } ``` -------------------------------- ### Terraform Configuration for Event Hub Deployment Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/examples/eventhub-with-existing-namespace/README.md This Terraform configuration sets up the necessary providers and modules to deploy an Event Hub into an existing namespace. It includes provider requirements, resource group creation, and the main event hub module configuration. ```hcl terraform { required_version = ">= 1.3.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = "~> 4.0" } } } provider "azurerm" { features {} skip_provider_registration = true } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.3.0" } # This is required for resource modules resource "azurerm_resource_group" "this" { location = "australiaeast" name = module.naming.resource_group.name_unique } resource "azurerm_eventhub_namespace" "this" { location = azurerm_resource_group.this.location name = module.naming.eventhub.name_unique resource_group_name = azurerm_resource_group.this.name sku = "Standard" } locals { event_hubs = { event_hub_existing_namespace = { namespace_name = module.event_hub.resource.id partition_count = 2 message_retention = 3 resource_group_name = module.event_hub.resource.name } # Add more event hubs if needed } } module "event_hub" { source = "../../" location = azurerm_resource_group.this.location name = module.naming.eventhub_namespace.name_unique resource_group_name = azurerm_resource_group.this.name # source = "Azure/avm--/azurerm" # ... enable_telemetry = false event_hubs = local.event_hubs existing_parent_resource = { name = azurerm_eventhub_namespace.this.name } } ``` -------------------------------- ### Map Telemetry to Root Variable in Terraform Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/AGENTS.md Map the 'enable_telemetry' setting to a root variable to control telemetry collection at the project level. This is a standard practice for AVM modules. ```terraform enable_telemetry = var.enable_telemetry ``` -------------------------------- ### Pin Module Version in Terraform Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/AGENTS.md When using AVM modules, always pin to a specific version for predictable deployments. This ensures consistency across environments. ```terraform version = "1.2.3" ``` -------------------------------- ### Terraform Configuration for Event Hub Capture Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/examples/eventhub-capture/README.md This Terraform configuration deploys an Azure Event Hub namespace with capture enabled. It sets up the necessary storage account and container for capturing events and assigns the required permissions. Ensure you have the 'azurerm' provider configured. ```hcl terraform { required_version = ">= 1.3.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = "~> 4.0" } } } provider "azurerm" { features {} skip_provider_registration = true } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.3.0" } # This is required for resource modules resource "azurerm_resource_group" "this" { location = "australiaeast" name = module.naming.resource_group.name_unique } # Get the current client details of the principal running terraform, used to apply RBAC permissions data "azurerm_client_config" "this" {} resource "azurerm_storage_account" "this" { account_replication_type = "ZRS" account_tier = "Standard" location = azurerm_resource_group.this.location name = module.naming.storage_account.name_unique resource_group_name = azurerm_resource_group.this.name } resource "azurerm_storage_container" "this" { name = "capture" container_access_type = "private" storage_account_name = azurerm_storage_account.this.name } resource "azurerm_role_assignment" "this" { principal_id = data.azurerm_client_config.this.object_id scope = azurerm_storage_container.this.resource_manager_id role_definition_name = "Storage Blob Data Contributor" } locals { event_hubs = { eh_capture_example = { namespace_name = module.event_hub.resource.id partition_count = 1 message_retention = 7 resource_group_name = module.event_hub.resource.name capture_description = { enabled = true encoding = "Avro" destination = { archive_name_format = "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}" blob_container_name = azurerm_storage_account.this.name storage_account_id = azurerm_storage_account.this.id } } } # Add more event hubs if needed } } module "event_hub" { source = "../../" location = azurerm_resource_group.this.location name = module.naming.eventhub_namespace.name_unique resource_group_name = azurerm_resource_group.this.name # source = "Azure/avm--/azurerm" # ... enable_telemetry = var.enable_telemetry event_hubs = local.event_hubs depends_on = [ azurerm_role_assignment.this ] } ``` -------------------------------- ### Configure Private Endpoints for Event Hubs Namespace Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/README.md Defines the configuration for private endpoints associated with an Event Hubs Namespace. This includes subresource names, DNS zone configurations, and IP settings. ```terraform subresource_name = string # NOTE: `subresource_name` can be excluded if the resource does not support multiple sub resource types (e.g. storage account supports blob, queue, etc) private_dns_zone_group_name = optional(string, "default") private_dns_zone_resource_ids = optional(set(string), []) application_security_group_associations = optional(map(string), {}) private_service_connection_name = optional(string, null) network_interface_name = optional(string, null) location = optional(string, null) resource_group_name = optional(string, null) ip_configurations = optional(map(object({ name = string private_ip_address = string })), {}) })) ``` -------------------------------- ### Use Pessimistic Constraints for Providers in Terraform Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/AGENTS.md When defining provider versions in Terraform, use pessimistic constraints (e.g., "~> 1.0") to allow for minor updates while preventing breaking changes. ```terraform version = "~> 1.0" ``` -------------------------------- ### Terraform Configuration for Event Hub Namespace Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/examples/default/README.md This HCL code block defines the Terraform configuration, including required providers and the deployment of an Event Hub Namespace module. It ensures unique naming for resources and sets up the necessary provider configurations. ```hcl terraform { required_version = ">= 1.3.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = "~> 4.0" } } } provider "azurerm" { features {} skip_provider_registration = true } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.3.0" } # This is required for resource modules resource "azurerm_resource_group" "this" { location = "AustraliaEast" name = module.naming.resource_group.name_unique } module "event_hub" { source = "../../" location = azurerm_resource_group.this.location name = module.naming.eventhub_namespace.name_unique resource_group_name = azurerm_resource_group.this.name # source = "Azure/avm--/azurerm" # ... enable_telemetry = false } ``` -------------------------------- ### Terraform Configuration for Event Hubs and Role Assignments Source: https://github.com/azure/terraform-azurerm-avm-res-eventhub-namespace/blob/main/examples/multiple-eventhubs/README.md This HCL code defines the Terraform configuration, including provider requirements, module definitions for naming and Event Hubs, resource group, storage account for capture, and role assignments for data access. ```hcl terraform { required_version = ">= 1.3.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = "~> 4.0" } } } provider "azurerm" { features {} skip_provider_registration = true } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.3.0" } # This is required for resource modules resource "azurerm_resource_group" "this" { location = "australiaeast" name = module.naming.resource_group.name_unique } # Get the current client details of the principal running terraform, used to apply RBAC permissions data "azurerm_client_config" "this" {} resource "azurerm_storage_account" "this" { account_replication_type = "ZRS" account_tier = "Standard" location = azurerm_resource_group.this.location name = module.naming.storage_account.name_unique resource_group_name = azurerm_resource_group.this.name } resource "azurerm_storage_container" "this" { name = "capture" container_access_type = "private" storage_account_name = azurerm_storage_account.this.name } resource "azurerm_role_assignment" "this" { principal_id = data.azurerm_client_config.this.object_id scope = azurerm_storage_container.this.resource_manager_id role_definition_name = "Storage Blob Data Contributor" } locals { event_hubs = { eh_capture_example = { namespace_name = module.event_hub.resource.id partition_count = 1 message_retention = 7 resource_group_name = module.event_hub.resource.name capture_description = { enabled = true encoding = "Avro" destination = { archive_name_format = "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}" blob_container_name = azurerm_storage_container.this.name storage_account_id = azurerm_storage_account.this.id } } role_assignments = { eh_sender_role = { role_definition_id_or_name = "Azure Event Hubs Data sender" principal_id = data.azurerm_client_config.this.object_id } } }, eh_another_hub = { namespace_name = module.event_hub.resource.id partition_count = 2 message_retention = 3 resource_group_name = module.event_hub.resource.name role_assignments = { eh_receiver_role = { role_definition_id_or_name = "Azure Event Hubs Data receiver" principal_id = data.azurerm_client_config.this.object_id } } } } } module "event_hub" { source = "../../" location = azurerm_resource_group.this.location name = module.naming.eventhub_namespace.name_unique resource_group_name = azurerm_resource_group.this.name # source = "Azure/avm--/azurerm" # ... enable_telemetry = var.enable_telemetry event_hubs = local.event_hubs depends_on = [ azurerm_role_assignment.this ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.