trek10inc / awsume

A utility for easily assuming AWS IAM roles from the command line.
https://awsu.me
MIT License
487 stars 90 forks source link

awsumepy slow on looping over multiple profiles #134

Closed tgmedia-nz closed 7 months ago

tgmedia-nz commented 3 years ago

Hi guys,

I've been using awsume daily, such a great tool, thanks heaps!

I'm facing a problem and I can't determine what it is, been trying to search the internet but no results, unfortunately. Tried to strace the process and enabling some other debugging but just can't pin-point it.

Running v4.5.0, Mac, bash, python 3.9.1

Issue: When writing a python script using awsumepy and looping over a few accounts, say 20, the process is slowing to a near halt and eating up all CPU resources. The output also is about to stop :)

Simple example:

from awsume.awsumepy import awsume
import time

# change to some existing profiles
profiles = ['test1', 'test2', 'test3']
# make the list bigger to trigger problem
profiles.extend(6*profiles)

for profile in profiles:
    start = time.time()
    print(f'using {profile}')
    s = awsume(profile)
    end = time.time()
    print(f'timediff: {end - start}')

Ideas? or ideas on how to debug?

Cheers, Thomas

mtskillman commented 9 months ago

in a nutshell the lag here is due to creating numerous unique AWS boto3 sdk objects upon calling awsume many times. we will adjust awsume/awsumepy/awsume.py to account for this scenario.

mtskillman commented 7 months ago

closed by https://github.com/trek10inc/awsume/pull/234

tgmedia-nz commented 7 months ago

Can confirm this fixed it - legends! thanks heaps