Skip to content

Commit

Permalink
return success message in case of stack deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
dasfmi committed Jul 23, 2024
1 parent 41ce078 commit 3e194b7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ def create_subscription_filter(log_group_arn: str, lambda_arn: str):


def lambda_handler(event: dict, context=None):
# handle deletion of the stack
if event["RequestType"] == "Delete":
cfnresponse.send(event, context, cfnresponse.SUCCESS, {}, event["PhysicalResourceId"])
return

if (
axiom_cloudwatch_forwarder_lambda_arn is None
or axiom_cloudwatch_forwarder_lambda_arn == ""
Expand Down Expand Up @@ -148,10 +153,12 @@ def lambda_handler(event: dict, context=None):

# if the log group already have a subscription filter, skip it
try:
response = cloudwatch_logs_client.describe_subscription_filters(logGroupName=group['name'])
response = cloudwatch_logs_client.describe_subscription_filters(
logGroupName=group["name"]
)
print(response)
# TODO: improve the Subscription filters check
if len(response['subscriptionFilters']) > 0:
if len(response["subscriptionFilters"]) > 0:
logger.info(f"Subscription filter already exists for {cleaned_name}")
continue
except Exception as e:
Expand Down

0 comments on commit 3e194b7

Please sign in to comment.