-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap
executable file
·49 lines (43 loc) · 1.42 KB
/
bootstrap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
#
# Golang executables that use the `aws-lambda-go` module are their own runtimes
# and do not need a custom runtime handler.
#
# This runtime bootstrap only exists to, when using the `provided.al2` runtime,
# enable the "handler" configuration value for a Lambda function to be whatever
# the user chooses (instead of `bootstrap`).
#
set -eu -o pipefail
exec_path="${LAMBDA_TASK_ROOT}/${_HANDLER}"
#
# Only basic existence and executable bit checks are done to ensure that the
# function handler can be called. Handlers compiled for the wrong archtecture
# are the user's problem.
#
if [ ! -e "${exec_path}" ];
then
echo "Handler file not found at path: ${exec_path}" >> /dev/stderr
curl --silent -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/init/error" \
--header "Lambda-Runtime-Function-Error-Type: Runtime.NoSuchHandler" \
--data - <<-JSON
{
"errorMessage": "Handler file not found at path: ${exec_path}",
"errorType": "InvalidFunctionException"
}
JSON
exit 10
fi
if [ ! -x "${exec_path}" ];
then
echo "Handler file not executable: ${exec_path}" >> /dev/stderr
curl --silent -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/init/error" \
--header "Lambda-Runtime-Function-Error-Type: Runtime.NoSuchHandler" \
--data - <<-JSON
{
"errorMessage": "Handler file not executable: ${exec_path}",
"errorType": "InvalidFunctionException"
}
JSON
exit 10
fi
exec "${exec_path}"