Skip to content

Commit 3a7e14b

Browse files
author
Graham Krizek
committed
Set HOME to /tmp
1 parent ba36007 commit 3a7e14b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ Bash behaves in ways unlike other programming languages. As such, there are some
7171

7272
### Notes
7373

74-
- Files to configure the AWS CLI are in `/tmp/.aws`. By default, the CLI uses the same region and IAM Role as your lambda function. If you need to set something different, you can use the `/tmp/.aws/config` and `/tmp/.aws/credentials` files accordingly.
74+
- `$HOME` is set to `/tmp`. This is because the Lambda filesystem is read-only except for the `/tmp` directory. Some programs require `$HOME` to be writeable (like the AWS CLI and some SSH commands), so this allows them to work without issue.
75+
76+
- Files to configure the AWS CLI should be put in `/tmp/.aws`. By default, the CLI uses the same region and IAM Role as your lambda function. If you need to set something different, you can use the `/tmp/.aws/config` and `/tmp/.aws/credentials` files accordingly.
7577

7678
- When using curl, you should use the `-s` flag. Without the silent flag, curl will send the progress bar of your request to `stderr`. This will show up in your response. So it's usually best to disable the progress bar.
7779

bootstrap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -uo pipefail
55
# Constants
66
RUNTIME_PATH="2018-06-01/runtime"
77
mkdir -p /tmp/.aws
8+
export HOME="/tmp"
89

910
# Send initialization error to Lambda API
1011
sendInitError () {
@@ -51,8 +52,6 @@ do
5152
export AWS_LAMBDA_DEADLINE_MS=$(grep -Fi Lambda-Runtime-Deadline-Ms "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
5253
export AWS_LAMBDA_FUNCTION_ARN=$(grep -Fi Lambda-Runtime-Invoked-Function-Arn "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
5354
export AWS_LAMBDA_TRACE_ID=$(grep -Fi Lambda-Runtime-Trace-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
54-
export AWS_CONFIG_FILE="/tmp/.aws/config"
55-
export AWS_SHARED_CREDENTIALS_FILE="/tmp/.aws/credentials"
5655
# Execute the user function
5756
$(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA" >&1 2> $RESPONSE | cat
5857
EXIT_CODE=$?

0 commit comments

Comments
 (0)