From 8a025743034ee62fce3448d9881cf9d81bfa653c Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Mon, 8 May 2023 14:52:28 +0200 Subject: [PATCH] fix(sagemaker): Handle ValidationException (#2321) --- .../aws/services/sagemaker/sagemaker_service.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/prowler/providers/aws/services/sagemaker/sagemaker_service.py b/prowler/providers/aws/services/sagemaker/sagemaker_service.py index c43a891e..5f0a8435 100644 --- a/prowler/providers/aws/services/sagemaker/sagemaker_service.py +++ b/prowler/providers/aws/services/sagemaker/sagemaker_service.py @@ -1,6 +1,7 @@ import threading from typing import Optional +from botocore.client import ClientError from pydantic import BaseModel from prowler.lib.logger import logger @@ -115,9 +116,19 @@ class SageMaker: try: for notebook_instance in self.sagemaker_notebook_instances: regional_client = regional_clients[notebook_instance.region] - describe_notebook_instance = regional_client.describe_notebook_instance( - NotebookInstanceName=notebook_instance.name - ) + try: + describe_notebook_instance = ( + regional_client.describe_notebook_instance( + NotebookInstanceName=notebook_instance.name + ) + ) + except ClientError as error: + if error.response["Error"]["Code"] == "ValidationException": + logger.warning( + f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" + ) + + continue if ( "RootAccess" in describe_notebook_instance and describe_notebook_instance["RootAccess"] == "Enabled"