using request params and return the results as responses #!/bin/sh set -euo pipefail # Initialization - load function handler source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh" # Processing while true do HEADERS="$(mktemp)" # Get an event EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) # Execute the handler function from the script RESPONSE=$($(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA") # Send the response curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "$RESPONSE" done
AWS Lambda function. 3. Create sample project using SPM. 4. Make executable file (Using Docker: Swift 5 on Ubuntu 16.04). 5. Deploy executable file and bootstrap to AWS Lambda.
to shared libraries as a layer. And link dynamically when handling request in bootstrap. EXECUTABLE=$LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1)" /opt/swift-shared-libs/ld-linux-x86-64.so.2 --library-path /opt/swift-shared-libs/lib $EXECUTABLE
path and Set an environment variable. PYTHON_LIBRARY=/usr/lib64/libpython2.7.so.1.0 2. Deploy boto3 module as a layer. And set /opt/python as PYTHONPATH. $ docker run --privileged -it -v `pwd`:`pwd` -w `pwd` --rm amazonlinux $ yum install python2-pip $ pip install -t ./python boto3 $ zip -r boto3.zip python