This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·39 lines (38 loc) · 1.57 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
#!/bin/bash
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "| CSSE6440 CLOUD INFRA ASSIGNMENT |"
echo "| Shaoming Teng, 44660145 |"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "> Before begin to depoly, please make sure the following requirements are met:"
echo -e "> Please make sure \033[1m\033[31mPython3.10\033[0m, Python library \033[1m\033[31mpsycopg2\033[0m and \033[1m\033[31mDocker\033[0m are installed on local machine, they are used to upload init data to database."
echo ""
#read -p "Press any key to continue... " -n1 -s
echo ""
echo "Continuing..."
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "> Zip lambda function"
cd ./lambda_hamilton || exit
# zip folder bin and psycopg2 and file lambda_function to lambda_function.zip
zip -r lambda_function_payload.zip bin/ psycopg2/ lambda_function.py
cd ..
echo "> Generated lambda_hamilton/lambda_function_payload.zip"
echo "Copying credential file to terraform"
cp ./credentials ./terraform/credentials || exit
echo "chdir to terraform folder"
cd ./terraform || exit
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "> Begin deploying..."
terraform init
terraform apply -var-file="secret.tfvars" -auto-approve
echo "Deploying Done."
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "Fetching API URL..."
API_URL=$(terraform output -raw api_url)
echo "API URL: $API_URL"
# Build a file called api.txt which the URL in it
echo "$API_URL" > ../api.txt
cd ..
# sleep 30 seconds
echo "Sleeping for 60 seconds... wait for everything is set up on cloud"
sleep 60
echo "Deploying Done."