From 66f7fc2000397713d408b678cb58a7e325f0d58e Mon Sep 17 00:00:00 2001 From: Gabriel Soltz <8935378+gabrielsoltz@users.noreply.github.com> Date: Sun, 19 Nov 2023 15:42:30 +0100 Subject: [PATCH] avoid-errors-when-no-organization (#60) --- lib/context/context.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/context/context.py b/lib/context/context.py index 46d4472..7dd5719 100644 --- a/lib/context/context.py +++ b/lib/context/context.py @@ -267,12 +267,20 @@ def get_account_organizations(self): "OU": organizations_ou, } except ClientError as err: - self.logger.error( - "Failed to describe_account: %s, for resource: %s - %s", - self.resource_account_id, - self.resource_arn, - err, - ) + if err.response["Error"]["Code"] == "AWSOrganizationsNotInUseException": + self.logger.info( + "Failed to describe_account: %s, for resource: %s - %s", + self.resource_account_id, + self.resource_arn, + err, + ) + else: + self.logger.warning( + "Failed to describe_account: %s, for resource: %s - %s", + self.resource_account_id, + self.resource_arn, + err, + ) return organizations