From 5daa104a6ebfb2f84d10b0fdfd92b1be9c207a9a Mon Sep 17 00:00:00 2001 From: Josh Kaplinsky <37640086+jkapdev@users.noreply.github.com> Date: Thu, 17 Feb 2022 06:39:43 -0600 Subject: [PATCH] fix policy attribute exception (#4868) --- moto/iam/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/moto/iam/models.py b/moto/iam/models.py index e06891782..a5456f40c 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -2339,7 +2339,8 @@ class IAMBackend(BaseBackend): user.delete_policy(policy_name) def delete_policy(self, policy_arn): - del self.managed_policies[policy_arn] + policy = self.get_policy(policy_arn) + del self.managed_policies[policy.arn] def create_access_key(self, user_name=None, status="Active"): user = self.get_user(user_name)