Fix an exception handling for LifecyclePolicyNotFoundException

This commit is contained in:
skyuecx0630 2024-08-06 14:22:08 +09:00
parent 9449cac446
commit fb3227e265

View File

@ -36,8 +36,11 @@ def ecr_private_lifecycle_policy_configured():
repositoryName=repository["repositoryName"], repositoryName=repository["repositoryName"],
) )
compliant_resource.append(repository["repositoryArn"]) compliant_resource.append(repository["repositoryArn"])
except botocore.errorfactory.LifecyclePolicyNotFoundException: except Exception as e:
if e.__class__.__name__ == "LifecyclePolicyNotFoundException":
non_compliant_resources.append(repository["repositoryArn"]) non_compliant_resources.append(repository["repositoryArn"])
else:
raise e
return RuleCheckResult( return RuleCheckResult(
passed=not non_compliant_resources, passed=not non_compliant_resources,