Skip to content

Commit

Permalink
Add check for NoneType to fix bug
Browse files Browse the repository at this point in the history
Bug disrupts the lambda run when it can't assume the role and isn't handled
  • Loading branch information
bc-jcarlson committed Aug 22, 2024
1 parent aff6497 commit 131421e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion utils/utils_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 131421e

Please sign in to comment.