Skip to content

Commit 45fdc75

Browse files
authored
Merge pull request #215 from IevIe/terraform-stack
Exclude suspended accounts for terraform deployment
2 parents 9e9e14e + 558516d commit 45fdc75

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

aws_sra_examples/terraform/solutions/terraform_stack.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ def get_accounts() -> list:
6868
organizations = boto3.client("organizations")
6969
paginator = organizations.get_paginator("list_accounts")
7070

71-
accounts = [account["Id"] for page in paginator.paginate() for account in page["Accounts"]]
71+
accounts = []
72+
for page in paginator.paginate():
73+
for account in page["Accounts"]:
74+
if account["Status"] == "ACTIVE":
75+
accounts.append(account["Id"])
76+
7277
audit_account = get_audit_account()
7378

7479
# audit account needs to go last

0 commit comments

Comments
 (0)