INNER CODE UNIT · Python
run_cleanup
mlevit/aws-auto-cleanup · app/src/main.py:60
def run_cleanup(self):
if self.dry_run:
self.logging.info("Auto Cleanup started in DRY RUN mode.")
else:
self.logging.info(f"Auto Cleanup started in DESTROY mode.")
for region in sorted(self.settings.get("regions")):
if self.settings.get("regions").get(region).get("clean"):
self.logging.info(f"Switching to '{region}' region.")
# check if the region is enabled within the account
try:
client_sts = boto3.client("sts", region_name=region)
client_sts.get_caller_identity()
except:
self.logging.info(
f"Skipping region '{region}' as it is not enabled within the current account."
)