Skip to content

Commit af9811a

Browse files
author
Graham Krizek
committed
setup aws cli in bootstrap
1 parent a244c1f commit af9811a

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

.aws/config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[default]

.aws/credentials

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[default]

bootstrap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ set -uo pipefail
44

55
# Constants
66
RUNTIME_PATH="2018-06-01/runtime"
7+
mkdir -p /tmp/.aws
8+
mv .aws/config /tmp/.aws/config
9+
mv .aws/credentials /tmp/.aws/credentials
710

811
# Send initialization error to Lambda API
912
sendInitError () {
@@ -45,8 +48,16 @@ do
4548
RESPONSE="$(mktemp)"
4649
EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/${RUNTIME_PATH}/invocation/next")
4750
REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
51+
#export PYTHONPATH="/var/task/bin/site-packages"
52+
# Export some additional context
53+
export AWS_LAMBDA_REQUEST_ID=$REQUEST_ID
54+
export AWS_LAMBDA_DEADLINE_MS=$(grep -Fi Lambda-Runtime-Deadline-Ms "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
55+
export AWS_LAMBDA_FUNCTION_ARN=$(grep -Fi Lambda-Runtime-Invoked-Function-Arn "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
56+
export AWS_LAMBDA_TRACE_ID=$(grep -Fi Lambda-Runtime-Trace-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
4857
# Workaround until this is a layer
4958
export PATH=$PATH:/var/task/bin
59+
export AWS_CONFIG_FILE="/tmp/.aws/config"
60+
export AWS_SHARED_CREDENTIALS_FILE="/tmp/.aws/credentials"
5061
# Execute the user function
5162
$(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA" >&1 2> $RESPONSE | cat
5263
EXIT_CODE=$?

0 commit comments

Comments
 (0)