-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathdeploy.sh
executable file
·57 lines (45 loc) · 1.27 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
46
47
48
49
50
51
52
53
54
55
56
57
# variables
stage=${STAGE}
region=${REGION}
bucket=${BUCKET}
secrets='/deploy/secrets/secrets.json'
# Configure your Serverless installation to talk to your AWS account
sls config credentials \
--provider aws \
--key ${SLS_KEY} \
--secret ${SLS_SECRET} \
--profile serverless-admin
# cd into functions dir
cd /deploy/functions
# Deploy functions
echo "------------------"
echo 'Deploying function...'
echo "------------------"
sls deploy
# find and replace the service endpoint
if [ -z ${stage+dev} ]; then echo "Stage is unset."; else echo "Stage is set to '$stage'."; fi
sls info -v | grep ServiceEndpoint > domain.txt
sed -i 's@ServiceEndpoint:\ https:\/\/@@g' domain.txt
sed -i "s@/$stage@@g" domain.txt
domain=$(cat domain.txt)
sed "[email protected].$region.amazonaws.com@@g" domain.txt > id.txt
id=$(cat id.txt)
echo "------------------"
echo "Domain:"
echo " $domain"
echo "------------------"
echo "API ID:"
echo " $id"
rm domain.txt
rm id.txt
echo "{\"DOMAIN\":\"$domain\"}" > $secrets
cd /deploy/bucket
# Deploy bucket config
echo "------------------"
echo 'Deploying bucket...'
sls deploy
echo "------------------"
echo 'Bucket endpoint:'
echo " http://$bucket.s3-website.$region.amazonaws.com/"
echo "------------------"
echo "Service deployed. Press CTRL+C to exit."