Skip to content

Instantly share code, notes, and snippets.

@dave-malone
Last active January 9, 2018 21:11
Show Gist options
  • Save dave-malone/cb9a23ac96918a77b912b5c6480a1715 to your computer and use it in GitHub Desktop.
Save dave-malone/cb9a23ac96918a77b912b5c6480a1715 to your computer and use it in GitHub Desktop.
Bash function that wraps the AWS cli to help make it easier to generate presign urls
aws_s3_presign(){
if [ -z "$1" ]; then
echo "1st arg is the key for the s3 object to presign, and may not be empty"
return
fi
if [ -z "$2" ]; then
echo "2nd arg is the number of days that the presigned url is valid for, and may not be empty"
return
fi
aws s3 ls $1
if [ $? -ne 0 ]; then
echo "$1 does not exist"
return
fi
aws s3 presign s3://$1 --expires-in $((60 * 60 * 24 * $2))
}
@dave-malone
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment