Handler script for Bash function calls
Written by
Updated at July 2, 2026
A request handler script is called to handle each invocation of a function in Bash. When creating a function version, you must specify the entry point, i.e., the extension file name, e.g., handler.sh.
The runtime delivers the request body in JSON format to the script via stdin.
The script stores service information in these environment variables:
REQUEST_ID: Request ID.FUNCTION_NAME: Function ID.FUNCTION_VERSION: Function version ID.
After processing, the function returns the stdout contents in JSON format.
Examples
The following function outputs the request structure and environment variables to both the execution log and function response:
#!/bin/bash
set -e
RESPONSE=$(cat | jq -sc '.[0] // {}' | jq -c '{statusCode:200, body:{env:env, request:.}}')
echo $RESPONSE >&2
echo $RESPONSE | jq -c '.body |= tostring' # make sure 'body' is a string, not a json node