in src/SimpleReplay/extract.py [0:0]
def validate_config_file(config_file):
if config_file["source_cluster_endpoint"]:
if (
not len(config_file["source_cluster_endpoint"].split(".")) == 6
or not len(config_file["source_cluster_endpoint"].split(":")) == 2
or not len(config_file["source_cluster_endpoint"].split("/")) == 2
or not ".redshift.amazonaws.com:" in config_file["source_cluster_endpoint"]
):
logger.error(
'Config file value for "source_cluster_endpoint" is not a valid endpoint. Endpoints must be in the format of <cluster-name>.<identifier>.<region>.redshift.amazonaws.com:<port>/<database-name>.'
)
exit(-1)
if not config_file["master_username"]:
logger.error(
'Config file missing value for "master_username". Please provide a value or remove the "source_cluster_endpoint" value.'
)
exit(-1)
else:
if not config_file["log_location"]:
logger.error(
'Config file missing value for "log_location". Please provide a value for "log_location", or provide a value for "source_cluster_endpoint".'
)
exit(-1)
if not config_file["start_time"]:
logger.error(
'Config file is missing "start_time". Please provide a valid "start_time" for extract.'
)
exit(-1)
else:
try:
dateutil.parser.isoparse(config_file["start_time"])
except ValueError:
logger.error(
'Config file "start_time" value not formatted as ISO 8601. Please format "start_time" as ISO 8601 or remove its value.'
)
exit(-1)
if not config_file["end_time"]:
logger.error(
'Config file is missing "end_time". Please provide a valid "end_time" for extract.'
)
exit(-1)
else:
try:
dateutil.parser.isoparse(config_file["end_time"])
except ValueError:
logger.error(
'Config file "end_time" value not formatted as ISO 8601. Please format "end_time" as ISO 8601 or remove its value.'
)
exit(-1)
if not config_file["start_time"]:
logger.error(
'Config file missing value for "start_time". Please provide a value for "start_time".'
)
exit(-1)
if not config_file["end_time"]:
logger.error(
'Config file missing value for "end_time". Please provide a value for "end_time".'
)
exit(-1)
if not config_file["workload_location"]:
logger.error(
'Config file missing value for "workload_location". Please provide a value for "workload_location".'
)
exit(-1)
if not config_file["workload_location"].startswith("s3://") and os.path.exists(
config_file["workload_location"]
):
logger.error(
f'Output already exists in "{config_file["workload_location"]}". Please move or delete the existing directory, or change the "workload_location" value.'
)
exit(-1)
if config_file["source_cluster_system_table_unload_location"] and not config_file[
"source_cluster_system_table_unload_location"
].startswith("s3://"):
logger.error(
'Config file value for "source_cluster_system_table_unload_location" must be an S3 location (starts with "s3://"). Please remove this value or put in an S3 location.'
)
exit(-1)
if (
config_file["source_cluster_system_table_unload_location"]
and not config_file["source_cluster_system_table_unload_iam_role"]
):
logger.error(
'Config file missing value for "source_cluster_system_table_unload_iam_role". Please provide a value for "source_cluster_system_table_unload_iam_role", or remove the value for "source_cluster_system_table_unload_location".'
)
exit(-1)
if (
config_file["source_cluster_system_table_unload_location"]
and not config_file["unload_system_table_queries"]
):
logger.error(
'Config file missing value for "unload_system_table_queries". Please provide a value for "unload_system_table_queries", or remove the value for "source_cluster_system_table_unload_location".'
)
exit(-1)
if config_file["unload_system_table_queries"] and not config_file[
"unload_system_table_queries"
].endswith(".sql"):
logger.error(
'Config file value for "unload_system_table_queries" does not end with ".sql". Please ensure the value for "unload_system_table_queries" ends in ".sql". See the provided "unload_system_tables.sql" as an example.'
)
exit(-1)