def deploy()

in opensearch/setupCWSubscriptionFilter.py [0:0]


def deploy(cwLogGroupPrefix):
    # Create subscription filter for all CW Logs across regions for Amazon OpenSearch Service 
    for region in json.loads(REGIONS_TO_MONITOR):
        print("Starting to create CW Log filters for", region)
        # Create CW Logs client
        cw_logs_client = boto3.client('logs', region_name=region)
        response = cw_logs_client.describe_log_groups(
            logGroupNamePrefix=cwLogGroupPrefix
        )
        # Read response which is dict, and change that to json with quotes "
        json_response = json.dumps(response)

        # Parse JSON data to extract logGroups
        log_groups = json.loads(json_response)["logGroups"]
        for log_group in log_groups:
            print("Processing logGroups:", log_group["arn"])
            cw_logs_client.put_subscription_filter(
                logGroupName=log_group["logGroupName"],
                filterName=subscriptionFilterNamePrefix + log_group["logGroupName"] + "-" + region,
                filterPattern=' ',
                destinationArn='arn:aws:lambda:' + current_region + ':' + account_id + ':function:CWLogsToOpenSearch_monitoring'
            )