Skip to content

Commit

Permalink
perf(python): optimize aws_regions loop
Browse files Browse the repository at this point in the history
Previously, the loop over the aws_regions variable
reset the connexion to aws api endpoint on each iteration.

This commit optimze that by reset aws connection only once
for each aws regions.
  • Loading branch information
diodonfrost committed Dec 28, 2020
1 parent 2395f08 commit 204e58a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions package/nuke/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ def lambda_handler(event, context):
"network_acl": NukeNetworkAcl,
}

for key, value in _strategy.items():
if key not in exclude_resources:
for aws_region in aws_regions:
for aws_region in aws_regions:
for key, value in _strategy.items():
if key not in exclude_resources:
strategy = value(region_name=aws_region)
strategy.nuke(older_than_seconds)

no_older_than = [int(s) for s in older_than if s.isdigit() and s == "0"]
for key, value in _strategy_with_no_date.items():
if key not in exclude_resources and no_older_than == [0]:
for aws_region in aws_regions:
for aws_region in aws_regions:
for key, value in _strategy_with_no_date.items():
if key not in exclude_resources and no_older_than == [0]:
strategy = value(region_name=aws_region)
strategy.nuke()

0 comments on commit 204e58a

Please sign in to comment.