From 131421e056f77be4d925c4dffe398d8755db0826 Mon Sep 17 00:00:00 2001 From: Josh Carlson Date: Thu, 22 Aug 2024 12:04:58 -0400 Subject: [PATCH] Add check for NoneType to fix bug Bug disrupts the lambda run when it can't assume the role and isn't handled --- utils/utils_aws.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/utils_aws.py b/utils/utils_aws.py index a65fd88..a81161e 100644 --- a/utils/utils_aws.py +++ b/utils/utils_aws.py @@ -48,7 +48,10 @@ def assume_role(account, region_override="None"): try: assumed_role_object = generate_temporary_credentials(account, security_audit_role_name, external_id, project) - credentials = assumed_role_object["Credentials"] + if assumed_role_object: + credentials = assumed_role_object["Credentials"] + else: + raise RuntimeError(f"could not generate STS credentials for {security_audit_role_name} role in AWS account {account}") return create_session(credentials, region_override)