def iam_backend_detach_role_policy(policy_arn, role_name): try: role = moto_iam_backend.get_role(role_name) policy = role.managed_policies[policy_arn] policy.detach_from(role) except KeyError: raise IAMNotFoundException("Policy {0} was not found.".format(policy_arn))
def detach_role_policy(self, context: RequestContext, role_name: roleNameType, policy_arn: arnType) -> None: try: role = moto_iam_backend.get_role(role_name) policy = role.managed_policies[policy_arn] policy.detach_from(role) except KeyError: raise NoSuchEntityException( "Policy {0} was not found.".format(policy_arn))