Skip to content

Commit

Permalink
catch tag exception (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
athiruma authored Mar 6, 2025
1 parent e1d4e1b commit ef170b2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cloud_governance/common/clouds/aws/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import typeguard

from cloud_governance.common.logger.init_logger import logger
from cloud_governance.common.logger.logger_time_stamp import logger_time_stamp
from cloud_governance.main.environment_variables import environment_variables

Expand Down Expand Up @@ -46,8 +47,11 @@ def __tag_resources(self, client_method: Callable, resource_ids: list, tags: lis
:param tags_name:
:return:
"""
if tags_name == 'Tags':
client_method(Resources=resource_ids, Tags=tags)
try:
if tags_name == 'Tags':
client_method(Resources=resource_ids, Tags=tags)
except Exception as e:
logger.error(e)

@logger_time_stamp
def __split_run_bulks(self, iterable: list, limit: int = 1):
Expand All @@ -72,9 +76,11 @@ def tag_aws_resources(self, client_method: Callable, tags: list, resource_ids: l
:return:
"""
if tags:
bulk_resource_ids_list = self.__split_run_bulks(iterable=resource_ids, limit=self.__update_tag_bulks) # split the aws resource_ids into batches
bulk_resource_ids_list = self.__split_run_bulks(iterable=resource_ids,
limit=self.__update_tag_bulks) # split the aws resource_ids into batches
co = 0
cpu_based_resource_ids_list = self.__split_run_bulks(iterable=bulk_resource_ids_list, limit=self.__update_tag_bulks)
cpu_based_resource_ids_list = self.__split_run_bulks(iterable=bulk_resource_ids_list,
limit=self.__update_tag_bulks)
for cpu_based_resource_ids_list in cpu_based_resource_ids_list:
for resource_ids_list in cpu_based_resource_ids_list:
self.__tag_resources(client_method, resource_ids_list, tags)
Expand All @@ -85,7 +91,7 @@ def tag_aws_resources(self, client_method: Callable, tags: list, resource_ids: l
@typeguard.typechecked
def iter_client_function(func_name: Callable, output_tag: str, iter_tag_name: str, **kwargs):
"""
This method fetch all Items of the resource i.e: EC2, IAM
This method fetches all Items of the resource i.e: EC2, IAM
:param func_name:
:param output_tag:
:param iter_tag_name:
Expand Down

0 comments on commit ef170b2

Please sign in to comment.