Skip to content

Commit 040b515

Browse files
Script to deploy code to lambda, with dev/prod option. (#213)
* single command to deploy code to prod lambda * fixed typos * Fixed typo script.sh Co-authored-by: Aadi Bajpai <[email protected]> Co-authored-by: Aadi Bajpai <[email protected]>
1 parent 2cb8125 commit 040b515

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

script.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
#access key
4+
AK=$1
5+
#secret key
6+
SK=$2
7+
#mode (default is dev)
8+
mode=$3
9+
10+
#checks
11+
if [ -z "$AK" ];
12+
then
13+
echo "Invalid command"
14+
echo "command syntax is-> sh script.sh <Access key> <secret key>"
15+
exit
16+
elif [ -z "$SK" ];
17+
then
18+
echo "Invalid command"
19+
echo "syntax is-> sh script.sh <key> <secret>"
20+
exit
21+
elif [ ! -e "./serverless.yml" ]
22+
then
23+
echo "Please create and configure the serverless.yml file"
24+
echo "For quick setup, you can use the one from the repo itself"
25+
exit
26+
elif [ ! command -v serverless &> /dev/null ]
27+
then
28+
echo "serverless could not be found, please install it first"
29+
exit
30+
fi
31+
32+
if [ -z "$mode" ];
33+
then
34+
mode="dev"
35+
fi
36+
37+
#configure the credentials
38+
serverless config credentials \
39+
--provider aws \
40+
--key $AK \
41+
--secret $SK \
42+
--profile beacon \
43+
-o
44+
45+
if [ $? -ne 0 ]; then
46+
echo "Couldn't update your credentials, please check the logs!"
47+
echo "Trying serverless deploy..."
48+
fi
49+
50+
#deploy to aws
51+
serverless deploy \
52+
--stage $mode \
53+
--aws-profile beacon
54+
55+
if [ $? -ne 0 ]; then
56+
echo "Error with serverless deploy, please check the logs!"
57+
fi
58+
59+
60+
61+
62+
63+

0 commit comments

Comments
 (0)