From 7e96938cf7004bc9c7469d509ce1be48d5e0130a Mon Sep 17 00:00:00 2001 From: nitrocode <7775707+nitrocode@users.noreply.github.com> Date: Fri, 5 Jan 2024 22:44:16 -0600 Subject: [PATCH] feat: use account-map component for brownfield env Signed-off-by: nitrocode <7775707+nitrocode@users.noreply.github.com> --- modules/account-map/main.tf | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/account-map/main.tf b/modules/account-map/main.tf index 8431cebbb..bc893e0c4 100644 --- a/modules/account-map/main.tf +++ b/modules/account-map/main.tf @@ -6,10 +6,9 @@ locals { aws_partition = data.aws_partition.current.partition legacy_terraform_uses_admin = coalesce(var.legacy_terraform_uses_admin, !var.terraform_dynamic_role_enabled) - full_account_map = { - for acct in data.aws_organizations_organization.organization.accounts - : acct.name == var.root_account_aws_name ? var.root_account_account_name : acct.name => acct.id if acct.status != "SUSPENDED" - } + non_suspended_account_ids = [for k, v in data.aws_organizations_organization.organization.accounts : v.id if v.status != "SUSPENDED"] + + full_account_map = { for k, v in module.accounts.outputs.account_info_map : k => v.id if contains(local.non_suspended_account_ids, v.id) } iam_role_arn_templates = { for name, info in local.account_info_map : name => format(var.iam_role_arn_template_template, compact(