Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
 def iam_response_delete_policy(self):
     policy_arn = self._get_param("PolicyArn")
     if moto_iam_backend.managed_policies.get(policy_arn):
         moto_iam_backend.managed_policies.pop(policy_arn, None)
         template = self.response_template(GENERIC_EMPTY_TEMPLATE)
         return template.render(name="DeletePolicy")
     else:
         raise IAMNotFoundException("Policy {0} was not found.".format(policy_arn))