Skip to content

Instantly share code, notes, and snippets.

@kmurugulla
Created May 2, 2017 17:38
Show Gist options
  • Save kmurugulla/85a4d2d739326aa069c71b2d7e9a66ab to your computer and use it in GitHub Desktop.
Save kmurugulla/85a4d2d739326aa069c71b2d7e9a66ab to your computer and use it in GitHub Desktop.
To test upload speeds to S3 (uses AWS CLI)
#! /bin/bash
#Author : Kiran Murugulla
#Description : Script to create an asset and upload binary from local machine into an S3 bucket
usage="Usage: s3-cp-speed-test.sh bucketname filepath \n"
BUCKET=$1
FILE=$2
if [ ! $# -eq 2 ] ; then
echo -e "$usage"
exit 2
fi
echo -e "Starting Copy $FILE into s3 bucket $BUCKET"
FILESIZE=$(stat -c%s "$FILE")
#echo "Size of $FILENAME = $FILESIZE bytes."
START_TIME=$SECONDS
aws s3 cp $FILE s3://$BUCKET
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo -e "Completed uploading binaries ."
echo -e " File $FILE of size $FILESIZE bytes copied to s3 Bucket $BUCKET in : $(($ELAPSED_TIME/60)) min $(($ELAPSED_TIME%60)) sec \n"
echo ""
#Verify the file uploaded
echo -e "Verifying the File Copied over correctlly - S3 Listing "
echo ""
aws s3 ls s3://$BUCKET/$FILE
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment