-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
33 lines (30 loc) · 927 Bytes
/
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
#!/bin/bash
# Load environment variables from .env file
if [ -f .env ]; then
export $(cat .env | grep -v '#' | xargs)
else
echo "Error: .env file not found"
exit 1
fi
echo "creating lambda_package directory ..."
rm -R lambda_package
mkdir -p lambda_package
echo "installing dependencies in lambda_package ..."
pip install --target lambda_package -r ./lambda/requirements.txt
echo "copying lambda code to lambda_package ..."
cp ./lambda/* ./lambda_package
echo "building and deploying lambda ..."
cd lambda_package || exit 1
sam build
sam package \
--template-file template.yaml \
--output-template-file packaged.yaml \
--s3-bucket "${S3_BUCKET}" \
--region "${LAMBDA_REGION}"
sam deploy \
--template-file packaged.yaml \
--stack-name "${STACK_NAME}" \
--capabilities CAPABILITY_IAM \
--region "${LAMBDA_REGION}"
cd ..
echo "Lambda code successfully, built, packaged and deployed"