-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·69 lines (53 loc) · 2.04 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
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -e
STACK_NAME="alexa-metrolink-skill"
cd "$(dirname "$0")"
if [ -z "`which jq`" ] ; then
echo "Please install jq"
exit 1
fi
alexa_application_id=`jq -r .alexa_application_id secrets.json`
echo -n "Creating package..."
rm -f alexa_metrolink_skill.zip
cd virtualenv/lib/python3.9/site-packages/
zip -r9 ../../../../alexa_metrolink_skill.zip * >/dev/null
cd ../../../../
zip -g alexa_metrolink_skill.zip alexa_metrolink_skill.py >/dev/null
zip -g alexa_metrolink_skill.zip stop-names.json >/dev/null
echo " ✅"
version="`date +%Y%m%d.%H%M%S`"
echo -n "Generating CloudFormation template..."
infrastructure/cloudformation.py
echo " ✅"
echo -n "Finding code bucket..."
deployment_bucket=`virtualenv/bin/aws cloudformation describe-stack-resource \
--stack-name $STACK_NAME \
--logical-resource-id "MetrolinkSkillLambdaBucket" \
| jq -r .StackResourceDetail.PhysicalResourceId`
if [ "$deployment_bucket" == "" ] ; then
echo " ❎"
echo -n "Unable to find code bucket, doing create-stack..."
virtualenv/bin/aws cloudformation deploy \
--stack-name $STACK_NAME \
--template-file infrastructure/cloudformation.json \
--parameter-overrides AlexaApplicationId=$alexa_application_id \
--capabilities CAPABILITY_IAM
deployment_bucket=`virtualenv/bin/aws cloudformation describe-stack-resource \
--stack-name $STACK_NAME \
--logical-resource-id "MetrolinkSkillLambdaBucket" \
| jq -r .StackResourceDetail.PhysicalResourceId`
echo " ✅"
else
echo " ✅"
fi
echo -n "Uploading code..."
virtualenv/bin/aws s3 cp alexa_metrolink_skill.zip s3://$deployment_bucket/$version/alexa_metrolink_skill.zip
echo " ✅"
echo "Updating Lambda deployment..."
virtualenv/bin/aws cloudformation deploy \
--stack-name $STACK_NAME \
--template-file infrastructure/cloudformation.json \
--parameter-overrides Version=$version AlexaApplicationId=$alexa_application_id \
--capabilities CAPABILITY_IAM
echo " ✅"
# TODO: script changes to interaction model (if possible)