Skip to content

Commit

Permalink
max workers=8 default
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jan 2, 2026
1 parent b24cbae commit c805a53
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions local-app/python-tools/cross-organization/org_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
def tqdm(iterable, **kwargs): return iterable

# --- VERSIONING ---
__version__ = "1.5.2"
__version__ = "1.5.3"

class OrgTaskRunner:
def __init__(self, args):
Expand All @@ -31,7 +31,6 @@ def __init__(self, args):
self.start_time = 0

def log_print(self, message=""):
# Terminal output is managed by tqdm; this is for internal log buffering
self.output_log.append(message)

def get_ou_path(self, org_client, entity_id):
Expand All @@ -58,7 +57,6 @@ def process_account(self, acc, partition, tasks):
acc_id, acc_name = acc['Id'], acc['Name']
role_arn = f"arn:{partition}:iam::{acc_id}:role/{self.args.role_name}"

# Resolve OU Data (inherited from v1.2)
parents = org.list_parents(ChildId=acc_id).get('Parents', [])
raw_path, ou_id = self.get_ou_path(org, parents[0]['Id']) if parents else ("Orphaned", "N/A")
ou_path = raw_path if raw_path else "Root"
Expand Down Expand Up @@ -96,7 +94,6 @@ def run(self):
sts = session.client('sts')
partition = sts.get_caller_identity()['Arn'].split(':')[1]

# Load tasks & build dynamic filename suffix
tasks, check_names = [], []
if self.args.enable_checks:
sys.path.append(os.getcwd())
Expand All @@ -113,7 +110,7 @@ def run(self):
all_accounts.sort(key=lambda x: x['Name' if self.args.sort == 'name' else 'Id'].lower())

print("-" * 100)
print(f"AWS ORG TASK RUNNER - v{__version__} | Check: {check_suffix}")
print(f"AWS ORG TASK RUNNER - v{__version__} | Max Workers: {self.args.max_workers}")
print("-" * 100)

with ThreadPoolExecutor(max_workers=self.args.max_workers) as executor:
Expand All @@ -124,12 +121,10 @@ def run(self):
if data: self.full_results.append(data)
pbar.update(1)

# FINAL EXPORTS
if self.args.output:
ds = datetime.now().strftime("%Y-%m-%dT%H%M%S")
base = self.args.output if self.args.output != 'DEFAULT' else f"audit_results.{check_suffix}"

# Save CSV (Long Format)
with open(f"{base}.{ds}.csv", 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow(["account_id", "account_name", "account_alias", "ou_path", "ou_id", "region", "field_name", "field_value"])
Expand All @@ -138,7 +133,6 @@ def run(self):
for k, v in fields.items():
writer.writerow([acc["account_id"], acc["account_name"], acc["alias"], acc["ou_path"], acc["ou_id"], reg, k, v])

# Save JSON (Hierarchical)
with open(f"{base}.{ds}.json", 'w') as f:
json.dump(self.full_results, f, indent=2)

Expand All @@ -152,5 +146,6 @@ def run(self):
p.add_argument("--sort", choices=['id', 'name'], default='name')
p.add_argument("--output", nargs='?', const='DEFAULT')
p.add_argument("--enable-checks", nargs='+')
p.add_argument("--max-workers", type=int, default=4)
# Updated default to 8 workers
p.add_argument("--max-workers", type=int, default=8, help="Number of concurrent accounts to process (default: 8)")
OrgTaskRunner(p.parse_args()).run()

0 comments on commit c805a53

Please sign in to comment.