diff --git a/core/extract/extract.py b/core/extract/extract.py index d2ace40d..ff784ecf 100644 --- a/core/extract/extract.py +++ b/core/extract/extract.py @@ -6,6 +6,7 @@ import os import zipfile import time +import re import common.config as config_helper import common.log as log_helper from common import aws_service as aws_service_helper @@ -14,6 +15,16 @@ logger = logging.getLogger("WorkloadReplicatorLogger") +serverless_cluster_endpoint_pattern = ( + r"(.+)\.(.+)\.(.+).redshift-serverless(-dev)?\.amazonaws\.com:[0-9]{4,5}\/(.)+" +) + + +def is_serverless(config): + return bool( + re.fullmatch(serverless_cluster_endpoint_pattern, config["source_cluster_endpoint"]) + ) + def main(): @@ -66,7 +77,10 @@ def main(): if config.get("source_cluster_endpoint"): application = "WorkloadReplicator-Extract" - host = config.get("source_cluster_endpoint").split(".")[0] + if is_serverless(config): + host = f'redshift-serverless-{config.get("source_cluster_endpoint").split(".")[0]}' + else: + host = config.get("source_cluster_endpoint").split(".")[0] port = int(config.get("source_cluster_endpoint").split(":")[-1] .split("/")[0]) DbUser = config.get("master_username") diff --git a/core/replay/replay.py b/core/replay/replay.py index f42debeb..eb2f1d54 100644 --- a/core/replay/replay.py +++ b/core/replay/replay.py @@ -99,7 +99,10 @@ def main(): # setting application name for tracking application = "WorkloadReplicator-Replay" - host = config.get("target_cluster_endpoint").split(".")[0] + if is_serverless_endpoint: + host = f'redshift-serverless-{config.get("target_cluster_endpoint").split(".")[0]}' + else: + host = config.get("target_cluster_endpoint").split(".")[0] port = int(config.get("target_cluster_endpoint").split(":")[-1].split("/")[0]) DbUser = config.get("master_username") DbName = config.get("target_cluster_endpoint").split("/")[-1]