Created
February 8, 2017 18:51
-
-
Save flux627/e037fa65daa5c51d0103f5753c018f6c to your computer and use it in GitHub Desktop.
Bash function to help save typing when invoking Serverless service functions from the command line
This file contains 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
# Invoke serverless service | |
invoke() { | |
# | |
# Usage: | |
# $ invoke stage function_name [payload_name] | |
# | |
if [ "${1}" == "local" ]; then | |
stage="local" | |
else | |
stage="-s ${1}" | |
fi | |
payloads_dir="tests/payloads/" | |
if [ -z $3 ]; then | |
payload="${payloads_dir}${2}/default.json" | |
else | |
payload="${payloads_dir}${2}/${3}.json" | |
fi | |
if [ ! -f "${payload}" ]; then | |
echo $payload | |
echo "Payload does not exist." | |
return 1 | |
fi | |
time --format='%e seconds' serverless invoke $stage -f $2 -p $payload | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment