-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·45 lines (39 loc) · 1.28 KB
/
deploy.sh
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
#!/bin/bash
awsFuncNotFound=254
source ./.env
# Setup env vars
export AWS_DEFAULT_REGION=$AWS_REGION_NAME
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
# Check if exists
echo "Checking if function exists..."
aws lambda get-function \
--function-name $LAMBDA_FUNCTION_NAME &> /dev/null
if [ $? -eq 0 ]; then
echo "Function exists."
echo "Deleting function..."
aws lambda delete-function --function-name $LAMBDA_FUNCTION_NAME
echo "Deleted."
else
echo "Function does not exist.\n"
fi
echo "Creating function..."
aws lambda create-function \
--function-name $LAMBDA_FUNCTION_NAME \
--role $LAMBDA_FUNCTION_ROLE \
--zip-file fileb://dist/deployment-package.zip \
--runtime python3.8 \
--handler lambdaHandler.sendMessage \
--timeout 10 \
--environment "Variables={ \
AWS_REGION_NAME=$AWS_REGION_NAME, \
AWS_ENDPOINT_URL=$AWS_ENDPOINT_URL, \
UNUSED_MESSAGES_TABLE_NAME=$UNUSED_MESSAGES_TABLE_NAME, \
USED_MESSAGES_TABLE_NAME=$USED_MESSAGES_TABLE_NAME, \
TWILIO_ACCOUNT_SID=$TWILIO_ACCOUNT_SID, \
TWILIO_AUTH_TOKEN=$TWILIO_AUTH_TOKEN, \
RECIPIENT_PHONE=$RECIPIENT_PHONE, \
RECIPIENT_NAME=$RECIPIENT_NAME, \
SENDER_PHONE=$SENDER_PHONE, \
}" > /dev/null
echo "Function created."