Skip to content

Commit c18cbd0

Browse files
author
iru
authored
fix(bench): single-account data org handle (#36)
1 parent 14506e2 commit c18cbd0

File tree

1 file changed

+6
-4
lines changed
  • modules/services/cloud-bench

1 file changed

+6
-4
lines changed

modules/services/cloud-bench/main.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44

55
data "aws_caller_identity" "me" {}
66

7-
data "aws_organizations_organization" "org" {}
7+
data "aws_organizations_organization" "org" {
8+
count = var.is_organizational ? 1 : 0
9+
}
810

911
data "sysdig_secure_trusted_cloud_identity" "trusted_identity" {
1012
cloud_provider = "aws"
1113
}
1214

1315
locals {
14-
member_account_ids = var.is_organizational ? [for a in data.aws_organizations_organization.org.non_master_accounts : a.id] : []
16+
member_account_ids = var.is_organizational ? [for a in data.aws_organizations_organization.org[0].non_master_accounts : a.id] : []
1517

16-
benchmark_task_name = var.is_organizational ? "Organization: ${data.aws_organizations_organization.org.id}" : data.aws_caller_identity.me.account_id
18+
benchmark_task_name = var.is_organizational ? "Organization: ${data.aws_organizations_organization.org[0].id}" : data.aws_caller_identity.me.account_id
1719
accounts_scope_clause = var.is_organizational ? "aws.accountId in (\"${join("\", \"", local.member_account_ids)}\")" : "aws.accountId = \"${data.aws_caller_identity.me.account_id}\""
1820
regions_scope_clause = length(var.benchmark_regions) == 0 ? "" : " and aws.region in (\"${join("\", \"", var.benchmark_regions)}\")"
1921
}
@@ -137,6 +139,6 @@ resource "aws_cloudformation_stack_set_instance" "stackset_instance" {
137139
region = var.region
138140
stack_set_name = aws_cloudformation_stack_set.stackset[0].name
139141
deployment_targets {
140-
organizational_unit_ids = [for root in data.aws_organizations_organization.org.roots : root.id]
142+
organizational_unit_ids = [for root in data.aws_organizations_organization.org[0].roots : root.id]
141143
}
142144
}

0 commit comments

Comments
 (0)