From fb3227e26599c17584440411407b341f37d196d2 Mon Sep 17 00:00:00 2001 From: skyuecx0630 <48788794+skyuecx0630@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:22:08 +0900 Subject: [PATCH] Fix an exception handling for LifecyclePolicyNotFoundException --- services/ecr.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/ecr.py b/services/ecr.py index 00701a6..87c1c8e 100644 --- a/services/ecr.py +++ b/services/ecr.py @@ -36,8 +36,11 @@ def ecr_private_lifecycle_policy_configured(): repositoryName=repository["repositoryName"], ) compliant_resource.append(repository["repositoryArn"]) - except botocore.errorfactory.LifecyclePolicyNotFoundException: - non_compliant_resources.append(repository["repositoryArn"]) + except Exception as e: + if e.__class__.__name__ == "LifecyclePolicyNotFoundException": + non_compliant_resources.append(repository["repositoryArn"]) + else: + raise e return RuleCheckResult( passed=not non_compliant_resources,