File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed
cloud_Azure/terraform/module Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ locals {
55
55
56
56
# Turns on flow logs for all network security groups in requested resource groups
57
57
resource "azurerm_network_watcher_flow_log" "kentik_network_flow_log" {
58
- for_each = { for i in local . flat_nsgs : i . key => i . value }
58
+ for_each = { for nsg in local . flat_nsgs : nsg . key => nsg . value }
59
59
60
60
name = " ${ var . name } _flow_log_${ each . value . name } "
61
61
network_watcher_name = data. azurerm_network_watcher . network_watcher . name
Original file line number Diff line number Diff line change @@ -7,14 +7,15 @@ locals {
7
7
generated_storage_account_names = [for name in local . _alphanum_lowercase_names : substr (name, 0 , 24 )]
8
8
}
9
9
10
- # Creates one storage account per resource group to store flow logs
11
- # StorageAccounts are mapped 1:1 to resource_group_names and this fact is used to get storage account id for given resource group name
10
+ # Creates one storage account per nsg per resource group to store flow logs
11
+ # StorageAccounts are mapped 1:1+:1 to nsg(s) and resource_group_names
12
+ # Note that only one flow log can be associated with a storage account per region
12
13
resource "azurerm_storage_account" "logs_storage_account" {
13
- for_each = { for s , rg in var . resource_group_names : rg => s }
14
+ for_each = { for nsg in local . flat_nsgs : nsg . key => nsg . value }
14
15
15
- # use either custom name if one is provided, or generate one
16
- name = length (var . storage_account_names ) == length (var . resource_group_names ) ? var . storage_account_names [ each . value ] : local. generated_storage_account_names [each . value ]
17
- resource_group_name = each. key
16
+ # generate storage account per nsg per rg
17
+ name = local. generated_storage_account_names [each . value ]
18
+ resource_group_name = each. value . rg
18
19
location = var. location
19
20
account_tier = " Standard"
20
21
account_replication_type = " GRS"
Original file line number Diff line number Diff line change @@ -63,4 +63,4 @@ variable "flow_exporter_application_id" {
63
63
type = string
64
64
default = " a20ce222-63c0-46db-86d5-58551eeee89f"
65
65
description = " Kentik NSG Flow Exporter application ID"
66
- }
66
+ }
You can’t perform that action at this time.
0 commit comments