-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_lambda.sh
More file actions
executable file
·42 lines (32 loc) · 1.1 KB
/
Copy pathdeploy_lambda.sh
File metadata and controls
executable file
·42 lines (32 loc) · 1.1 KB
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
#!/bin/bash
# Set bash options
set -e -x
# Load environment variables from .env file
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
fi
# Define the name of the zip file
ZIP_FILE="lambda_function.zip"
# Function ARN from environment variable
FUNCTION_ARN=$FUNCTION_ARN
# Check if FUNCTION_ARN is set
if [ -z "$FUNCTION_ARN" ]
then
echo "ERROR: FUNCTION_ARN environment variable is not set."
exit 1
fi
rm -f $ZIP_FILE
zip -r $ZIP_FILE *.py html/
# Append the contents of the 'dependencies' directory at the root of the zip file
if [ -d "dependencies" ]; then
(cd dependencies && zip -rg ../$ZIP_FILE .)
fi
# Updating the Lambda function
aws lambda update-function-code --function-name $FUNCTION_ARN --zip-file fileb://$ZIP_FILE
aws lambda wait function-updated --function-name $FUNCTION_ARN
# Check if TEST_SNIPPET is set and file exists
if [ -n "$TEST_SNIPPET" ] && [ -f "$TEST_SNIPPET" ]; then
# Invoke the Lambda function using the contents of TEST_SNIPPET
aws lambda invoke --function-name $FUNCTION_ARN --payload file://$TEST_SNIPPET output.json
cat output.json |jq
fi