File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1- #! /bin/sh
1+ #! /bin/bash
22
33# https://docs.aws.amazon.com/lambda/latest/dg/runtimes-walkthrough.html
44# https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html
3333HANDLER_FILE=" $( echo $_HANDLER | cut -d. -f1) .sh"
3434HANDLER_FUNC=" $( echo $_HANDLER | cut -d. -f2) "
3535
36+ echo " HANDLER_FILE: $HANDLER_FILE " >&2
37+ echo " HANDLER_FUNC: $HANDLER_FUNC " >&2
38+ echo " LAMBDA_TASK_ROOT: $LAMBDA_TASK_ROOT " >&2
39+ echo " AWS_LAMBDA_RUNTIME_API: $AWS_LAMBDA_RUNTIME_API " >&2
40+ echo " Sourcing $LAMBDA_TASK_ROOT /$HANDLER_FILE " >&2
41+
42+
3643if [ ! -f " $LAMBDA_TASK_ROOT /$HANDLER_FILE " ]; then
3744 send_init_error " Handler file not found: $HANDLER_FILE "
3845fi
5562 REQUEST_ID=$( grep -Fi Lambda-Runtime-Aws-Request-Id " $HEADERS " | tr -d ' [:space:]' | cut -d: -f2)
5663
5764 # Run the handler function from the script with error handling
58- if RESPONSE=$( " $HANDLER_FUNC " " $EVENT_DATA " 2>&1 ) ; then
65+ # Let stderr go to CloudWatch logs, only capture stdout as response
66+ if RESPONSE=$( " $HANDLER_FUNC " " $EVENT_DATA " ) ; then
5967 # Success - send response
6068 echo " $RESPONSE " | curl -sS -X POST \
6169 " http://${AWS_LAMBDA_RUNTIME_API} /2018-06-01/runtime/invocation/${REQUEST_ID} /response" \
6270 -H " Content-Type: application/json" \
6371 -d @-
6472 else
6573 # Error - send error response
66- send_invocation_error " $REQUEST_ID " " Handler function failed: $RESPONSE "
74+ send_invocation_error " $REQUEST_ID " " Handler function failed with exit code $? "
6775 fi
6876
6977 rm -f " $HEADERS "
You can’t perform that action at this time.
0 commit comments