Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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) : []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if any values provided in var.ram_principals are computed, this will fail. in addition, the left side of the conditional is of type toset() and the right is tolist()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if any values provided in var.ram_principals are computed, this will fail.

You have a good point! I will fix it by using a local value.

in addition, the left side of the conditional is of type toset() and the right is tolist()

Why tolist()? The variable ram_principals is already a list, moreover for_each cannot iterate over lists as you know and that was the reason I used toset()... Did I miss something?


principal = var.ram_principals[count.index]
principal = each.value
resource_share_arn = aws_ram_resource_share.this[0].arn
}

Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}