Skip to content

Commit

Permalink
Merge pull request #215 from IevIe/terraform-stack
Browse files Browse the repository at this point in the history
Exclude suspended accounts for terraform deployment
  • Loading branch information
liamschn authored Jul 17, 2024
2 parents 9e9e14e + 558516d commit 45fdc75
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aws_sra_examples/terraform/solutions/terraform_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ def get_accounts() -> list:
organizations = boto3.client("organizations")
paginator = organizations.get_paginator("list_accounts")

accounts = [account["Id"] for page in paginator.paginate() for account in page["Accounts"]]
accounts = []
for page in paginator.paginate():
for account in page["Accounts"]:
if account["Status"] == "ACTIVE":
accounts.append(account["Id"])

audit_account = get_audit_account()

# audit account needs to go last
Expand Down

0 comments on commit 45fdc75

Please sign in to comment.