Skip to content

Instantly share code, notes, and snippets.

@flux627
Created February 8, 2017 18:51
Show Gist options
  • Save flux627/e037fa65daa5c51d0103f5753c018f6c to your computer and use it in GitHub Desktop.
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
# 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