#!/bin/bash
source "$ROOT_PATH"/scripts/common.sh
set -eo pipefail

# Function to handle errors
handle_error() {
    echo_red_bg "Error: $1"
    exit 1
}

file_name="$VERSION_TO_DEPLOY-$LAMBDA_NAME.zip"
if [[ "$ENV_NAME" == "production" && "$AWS_REGION" == "eu-west-1" ]]; then
    s3_bucket="qsase-prod-eu-env-files"
else
    s3_bucket="p81-$ENV_NAME-env-files"
fi

# Download the lambda to S3

echo "Dowloading the lambda from S3..."
aws s3 cp "s3://$s3_bucket/zips/$file_name" lambda.zip  || handle_error "Failed to dowload lambda from S3."
