Skip to content

Commit

Permalink
fix flake8 findings
Browse files Browse the repository at this point in the history
  • Loading branch information
liamschn committed Jul 15, 2024
1 parent 6d5d769 commit 88bbbd5
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
MAX_RETRIES = 12
SLEEP_TIME = 5


def assume_role(role: str, role_session_name: str, account: str = None, session: boto3.Session = None) -> boto3.Session:
"""Assumes the provided role in the given account and returns a session.
Expand Down Expand Up @@ -72,7 +73,7 @@ def assume_role(role: str, role_session_name: str, account: str = None, session:
)


def associate_admin_account(delegated_admin_account_id: str) -> None:
def associate_admin_account(delegated_admin_account_id: str) -> None: # noqa CCR001
"""Associate an administrator account for Firewall Manager.
Args:
Expand Down Expand Up @@ -106,19 +107,19 @@ def associate_admin_account(delegated_admin_account_id: str) -> None:
try:
firewall_manager_client.associate_admin_account(AdminAccount=delegated_admin_account_id)
associated = True
except botocore.exceptions.ClientError as error:
LOGGER.info(f"Attempt {i_retry} - error associating admin account: {error.response['Error']['Message']}")
except botocore.exceptions.ClientError as retry_error:
LOGGER.info(f"Attempt {i_retry} - error associating admin account: {retry_error.response['Error']['Message']}")
associated = False
if associated is True:
break
else:
i_retry += 1
if associated is False:
LOGGER.error("Unable to associate admin account.")
raise ValueError("Unable to associate admin account.")
raise ValueError("Unable to associate admin account.") from None
else:
LOGGER.error("Unexpected error. Unable to associate admin account due to error unrelated to an invalid operation.")
raise ValueError("Unexpected error. Unable to associate admin account due to error unrelated to an invalid operation.")
raise ValueError("Unexpected error. Unable to associate admin account due to error unrelated to an invalid operation.") from None
LOGGER.info("...Waiting 5 minutes for admin account association.")
time.sleep(300) # use 5 minute wait
while True:
Expand Down

0 comments on commit 88bbbd5

Please sign in to comment.