Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
errors.append(message)
else:
# remove the policy name if it's in the list
try:
policies_to_remove.remove(policy_name)
except Exception: # nosec
pass
if policies_to_remove:
for policy_name in policies_to_remove:
try:
LOGGER.info(
f"Deleting policy {policy_name} for rollback (role: {role.role_name} account {account_number})"
)
delete_role_policy(
RoleName=role.role_name, PolicyName=policy_name, **conn
)
except botocore.excpetions.ClientError as e:
message = "Unable to delete policy {}. Error: {} (role: {} account {})".format(
policy_name, e.message, role.role_name, account_number
)
LOGGER.error(message)
errors.append(message)
_update_role_data(
role,
dynamo_table,
account_number,
config,
conn,
Args:
name (string)
role (Role object)
account_number (string)
conn (dict)
Returns:
error (string) or None
"""
LOGGER.info(
"Deleting policy with name {} from {} in account {}".format(
name, role.role_name, account_number
)
)
try:
delete_role_policy(RoleName=role.role_name, PolicyName=name, **conn)
except botocore.exceptions.ClientError as e:
return "Error deleting policy: {} from role: {} in account {}. Exception: {}".format(
name, role.role_name, account_number, e
)