Last active
January 9, 2018 21:11
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires that the AWS cli be installed.
https://docs.aws.amazon.com/cli/latest/userguide/installing.html