Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Feb 24, 2023
1 parent 6a6700a commit d763a38
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions share-resources/share.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ locals {
{ share = lookup(sn.tags, "boc:vpc:route-table", null) != "attachment" && lookup(sn.tags, "share", true) ? true : false },
sn,
) }
shared_subnets = { for k, v in local.subnets : k => v if v.share }
}

data "aws_organizations_resource_tags" "accounts" {
Expand All @@ -21,7 +22,7 @@ data "aws_organizations_resource_tags" "organizational_units" {
}

resource "aws_ram_resource_share" "subnets" {
for_each = var.share_enabled ? local.subnets : {}
for_each = var.share_enabled ? local.shared_subnets : {}
name = format("%v_%v", var.vpc_full_name, each.value.label)
allow_external_principals = false

Expand Down Expand Up @@ -54,10 +55,10 @@ resource "aws_ram_resource_share" "subnets" {
# accounts
#---
locals {
share_account_map = { for p in setproduct(keys(local.subnets), var.share_account_list) : format("%v:%v", p[0], p[1]) => {
share_account_map = { for p in setproduct(keys(local.shared_subnets), var.share_account_list) : format("%v:%v", p[0], p[1]) => {
label = format("%v:%v", p[0], p[1])
subnet_id = p[0]
subnet_arn = local.subnets[p[0]].arn
subnet_arn = local.shared_subnets[p[0]].arn
account_id = p[1]
} }
}
Expand All @@ -78,10 +79,10 @@ resource "aws_ram_resource_association" "subnets_accounts" {
# organizational units
#---
locals {
share_organizational_unit_map = { for p in setproduct(keys(local.subnets), keys(local.share_ou_arns)) : format("%v:%v", p[0], p[1]) => {
share_organizational_unit_map = { for p in setproduct(keys(local.shared_subnets), keys(local.share_ou_arns)) : format("%v:%v", p[0], p[1]) => {
label = format("%v:%v", p[0], p[1])
subnet_id = p[0]
subnet_arn = local.subnets[p[0]].arn
subnet_arn = local.shared_subnets[p[0]].arn
organization_unit_id = p[1]
organization_unit_arn = local.share_ou_arns[p[1]]
} }
Expand Down

0 comments on commit d763a38

Please sign in to comment.