Skip to content

Commit

Permalink
more count to for_each conversion on outputs and cloudexport
Browse files Browse the repository at this point in the history
  • Loading branch information
jksprattler committed Nov 6, 2024
1 parent 4feae09 commit 32ed2ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cloud_Azure/terraform/module/cloudexport.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ provider "kentik-cloudexport" {

# Creates one Kentik CloudExport for every requested Resource Group
resource "kentik-cloudexport_item" "azure_export" {
count = length(var.resource_group_names)
for_each = { for idx, rg in var.resource_group_names : rg => idx }

name = "${var.name}-${var.resource_group_names[count.index]}-${var.subscription_id}" # resource group name + subscription id make the name unique
name = "${var.name}-${var.resource_group_names[each.value]}-${var.subscription_id}" # resource group name + subscription id make the name unique
type = "CLOUD_EXPORT_TYPE_KENTIK_MANAGED"
enabled = var.enabled
description = var.description
Expand All @@ -25,8 +25,8 @@ resource "kentik-cloudexport_item" "azure_export" {
azure {
subscription_id = var.subscription_id
location = var.location
resource_group = var.resource_group_names[count.index]
storage_account = azurerm_storage_account.logs_storage_account[count.index].name # storage accounts are mapped to resource groups 1:1
resource_group = var.resource_group_names[each.value]
storage_account = azurerm_storage_account.logs_storage_account[each.value].name # storage accounts are mapped to resource groups 1:1
security_principal_enabled = true
}
}
}
2 changes: 1 addition & 1 deletion cloud_Azure/terraform/module/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ output "resource_group_names" {
}

output "storage_accounts" {
value = azurerm_storage_account.logs_storage_account[*].name
value = azurerm_storage_account.logs_storage_account[each.key].name
description = "Storage Account names where flow logs will be collected"
}

Expand Down

0 comments on commit 32ed2ad

Please sign in to comment.