-
Notifications
You must be signed in to change notification settings - Fork 82
/
locals.telemetry.tf
66 lines (58 loc) · 3.2 KB
/
locals.telemetry.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Telemetry is collected by creating an empty ARM deployment with a specific name
# If you want to disable telemetry, you can set the disable_telemetry variable to true
locals {
# root_module_puid is the UUID that identifies the root module in the telemetry ARM deployment.
telem_root_puid = "50a8a460-d517-4b11-b86c-6de447806b67"
# telem_arm_subscription_template is the ARM template content for the telemetry deployment.
telem_arm_subscription_template = {
"$schema" = "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#"
contentVersion = "1.0.0.0"
parameters = {}
variables = {}
resources = []
outputs = {
telemetry = {
type = "String"
value = "For more information, see https://aka.ms/lz-vending/tf/telemetry"
}
}
}
# subscription telemetry bit fields
telem_root_subscription_alias_enabled = var.subscription_alias_enabled ? 1 : 0
telem_root_subscription_management_group_association_enabled = var.subscription_management_group_association_enabled ? 2 : 0
telem_root_subscription_tags_enabled = length(var.subscription_tags) > 0 ? 4 : 0
# virtualnetwork telemetry bit fields
telem_root_virtual_network_enabled = var.virtual_network_enabled ? 256 : 0
telem_root_virtual_network_peering_enabled = anytrue([for k, v in var.virtual_networks : v.hub_peering_enabled]) ? 512 : 0
telem_root_virtual_network_vwan_connection_enabled = anytrue([for k, v in var.virtual_networks : v.vwan_connection_enabled]) ? 1024 : 0
telem_virtual_network_resource_lock_enabled = anytrue([for k, v in var.virtual_networks : v.resource_group_lock_enabled]) ? 2048 : 0
telem_root_vwan_advanced_routing_enabled = anytrue([for k, v in var.virtual_networks : length(v.vwan_propagated_routetables_labels) > 0 || length(v.vwan_propagated_routetables_resource_ids) > 0 || v.vwan_associated_routetable_resource_id != ""]) ? 4096 : 0
# roleassignment telemetry bit fields
telem_root_role_assignment_enabled = var.role_assignment_enabled ? 65536 : 0
# Calculate the denary value of the bit fields
telem_root_bitfield_denary = (
local.telem_root_subscription_alias_enabled +
local.telem_root_subscription_management_group_association_enabled +
local.telem_root_subscription_tags_enabled +
local.telem_root_virtual_network_enabled +
local.telem_root_virtual_network_peering_enabled +
local.telem_root_virtual_network_vwan_connection_enabled +
local.telem_virtual_network_resource_lock_enabled +
local.telem_root_vwan_advanced_routing_enabled +
local.telem_root_role_assignment_enabled
)
# Convert the denary value to hexadecimal and pad with zeros to the left to a length of 8 characters.
telem_root_bitfield_hex = format("%08x", local.telem_root_bitfield_denary)
# This constructs the ARM deployment name that is used for the telemetry.
# We shouldn't ever hit the 64 character limit but use substr just in case
telem_root_arm_deployment_name = substr(
format(
"pid-%s_%s_%s",
local.telem_root_puid,
local.module_version,
local.telem_root_bitfield_hex,
),
0,
64
)
}