bridgecrewio / AirIAM

Least privilege AWS IAM Terraformer
https://airiam.io
Apache License 2.0
774 stars 78 forks source link

Error in iterating results #34

Closed owindsor closed 4 years ago

owindsor commented 4 years ago

Hi,

Get the following when trying to execute 'get_unused';

INFO:botocore.credentials:Found credentials in shared credentials file: ~/.aws/credentials
Reusing local data
Traceback (most recent call last):
  File "/home/user/.local/bin/airiam", line 5, in <module>
    run()
  File "/home/user/.local/lib/python3.8/site-packages/airiam/main.py", line 29, in run
    runtime_results = find_unused(logger, args.profile, args.no_cache, args.last_used_threshold, args.command)
  File "/home/user/.local/lib/python3.8/site-packages/airiam/find_unused/find_unused.py", line 49, in find_unused
    unused_users, used_users = find_unused_users(account_users, credential_report, unused_threshold)
  File "/home/user/.local/lib/python3.8/site-packages/airiam/find_unused/find_unused.py", line 69, in find_unused_users
    credentials = next(creds for creds in credential_report if creds['user'] == user['UserName'])
StopIteration

It pulls and populates the iam_data.json file then throws the error. Currently running v0.1.37.

owindsor commented 4 years ago

I rolled back through a set of versions, till I hit 0.1.32 when it worked - and now it works on the later version.

I'll check it out later to see if there were any dependency updates on the system

nimrodkor commented 4 years ago

Hi @owindsor !

Yes, it is a protection I've put in place not long ago to ensure the credentials used for running AirIAM aren't identified as unused and deleted by the tool. Added protection against StopIteration in the version that should be released in the coming minutes.

Thanks for reporting!