1
+ # #######################################################################################
2
+ # Deploy the Event hub items
3
+ # #######################################################################################
4
+ # Deploy the event hub namespace
5
+ resource "azurerm_eventhub_namespace" "avs_log_processing" {
6
+ name = var. eventhub_namespace_name
7
+ location = var. rg_location
8
+ resource_group_name = var. rg_name
9
+ sku = " Standard"
10
+ capacity = var. eventhub_capacity
11
+
12
+ tags = var. tags
13
+ }
14
+
15
+ # deploy the event hub
16
+ resource "azurerm_eventhub" "avs_log_processing" {
17
+ name = var. eventhub_name
18
+ namespace_name = azurerm_eventhub_namespace. avs_log_processing . name
19
+ resource_group_name = var. rg_name
20
+ partition_count = var. eventhub_partition_count
21
+ message_retention = var. eventhub_message_retention_days
22
+ }
23
+
24
+ # deploy the authorization rule for the diagnostic setting
25
+ resource "azurerm_eventhub_namespace_authorization_rule" "avs_log_processing" {
26
+ name = var. diagnostic_eventhub_authorization_rule_name
27
+ namespace_name = azurerm_eventhub_namespace. avs_log_processing . name
28
+ resource_group_name = var. rg_name
29
+
30
+ listen = true
31
+ send = true
32
+ manage = true
33
+ }
34
+
35
+ # deploy the authorization rule for the plugin
36
+ resource "azurerm_eventhub_authorization_rule" "avs_log_processing" {
37
+ name = var. logstash_eventhub_authorization_rule_name
38
+ namespace_name = azurerm_eventhub_namespace. avs_log_processing . name
39
+ eventhub_name = azurerm_eventhub. avs_log_processing . name
40
+ resource_group_name = var. rg_name
41
+
42
+ listen = true
43
+ send = true
44
+ manage = true
45
+ }
46
+
47
+ # deploy an eventhub consumer group for use by the logstash plugin
48
+ resource "azurerm_eventhub_consumer_group" "avs_log_processing" {
49
+ name = var. consumer_group_name
50
+ namespace_name = azurerm_eventhub_namespace. avs_log_processing . name
51
+ eventhub_name = azurerm_eventhub. avs_log_processing . name
52
+ resource_group_name = var. rg_name
53
+ }
54
+
55
+ # deploy a storage account for use by the eventhub plugin to maintain state
56
+ resource "azurerm_storage_account" "avs_log_processing" {
57
+ name = var. plugin_storage_account_name
58
+ resource_group_name = var. rg_name
59
+ location = var. rg_location
60
+ account_tier = " Standard"
61
+ account_replication_type = " LRS"
62
+
63
+ tags = var. tags
64
+ }
65
+
66
+ # ############################################################################################
67
+ # Telemetry Section - Toggled on and off with the telemetry variable
68
+ # This allows us to get deployment frequency statistics for deployments
69
+ # Re-using parts of the Core Enterprise Landing Zone methodology
70
+ # ############################################################################################
71
+ locals {
72
+ # create an empty ARM template to use for generating the deployment value
73
+ telem_arm_subscription_template_content = << TEMPLATE
74
+ {
75
+ "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
76
+ "contentVersion": "1.0.0.0",
77
+ "parameters": {},
78
+ "variables": {},
79
+ "resources": [],
80
+ "outputs": {
81
+ "telemetry": {
82
+ "type": "String",
83
+ "value": "For more information, see https://aka.ms/alz/tf/telemetry"
84
+ }
85
+ }
86
+ }
87
+ TEMPLATE
88
+ module_identifier = lower (" avs_event_hub_for_logs" )
89
+ telem_arm_deployment_name = " ${ lower (var. guid_telemetry )} .${ substr (local. module_identifier , 0 , 20 )} .${ random_string . telemetry . result } "
90
+ }
91
+
92
+ # create a random string for uniqueness
93
+ resource "random_string" "telemetry" {
94
+ length = 4
95
+ special = false
96
+ upper = false
97
+ lower = true
98
+ }
99
+
100
+ resource "azurerm_subscription_template_deployment" "telemetry_core" {
101
+ count = var. module_telemetry_enabled ? 1 : 0
102
+
103
+ name = local. telem_arm_deployment_name
104
+ location = var. rg_location
105
+ template_content = local. telem_arm_subscription_template_content
106
+ }
0 commit comments