From e56038ebbdaac34a6d113f89c5ca3d687c4d8b78 Mon Sep 17 00:00:00 2001 From: Emerson Barros Date: Thu, 22 Dec 2022 23:28:19 -0300 Subject: [PATCH] fix: change count for for_each into ram_principal_association resource and adjust the output related to this resource --- main.tf | 4 ++-- outputs.tf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 600e26e..a38a29a 100644 --- a/main.tf +++ b/main.tf @@ -161,9 +161,9 @@ resource "aws_ram_resource_association" "this" { } resource "aws_ram_principal_association" "this" { - count = var.create_tgw && var.share_tgw ? length(var.ram_principals) : 0 + for_each = var.create_tgw && var.share_tgw ? toset(var.ram_principals) : [] - principal = var.ram_principals[count.index] + principal = each.value resource_share_arn = aws_ram_resource_share.this[0].arn } diff --git a/outputs.tf b/outputs.tf index 8dcb8a5..94223ef 100644 --- a/outputs.tf +++ b/outputs.tf @@ -96,5 +96,5 @@ output "ram_resource_share_id" { output "ram_principal_association_id" { description = "The Amazon Resource Name (ARN) of the Resource Share and the principal, separated by a comma" - value = try(aws_ram_principal_association.this[0].id, "") + value = [for k, v in aws_ram_principal_association.this : v.id] }