#!/bin/bash # Check if AWS CLI is installed if ! command -v aws &> /dev/null; then echo "AWS CLI not found. Please install and configure the AWS CLI." exit 1 fi # Define the S3 key for the zip file and the local directory to save it S3_KEY="model-artifacts.zip" LOCAL_DIR="tmp" LOCAL_FILE="$LOCAL_DIR/model-artifacts.zip" # Create the local directory if it doesn't exist mkdir -p "$LOCAL_DIR" # Fetch the zip file from the S3 bucket and save it to the local directory echo "Fetching $S3_KEY from s3://$S3_BUCKET_NAME/ and saving it to $LOCAL_FILE..." aws s3 cp "s3://$S3_BUCKET_NAME/$S3_KEY" "$LOCAL_FILE" if [ $? -ne 0 ]; then echo "Failed to fetch $S3_KEY from s3://$S3_BUCKET_NAME/" exit 1 fi echo "$S3_KEY successfully fetched and saved to $LOCAL_FILE"