-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdeploy.sh
executable file
·57 lines (38 loc) · 1.16 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
#!/bin/bash
S3_BUCKET=$1
STACK_NAME=$2
TEMPLATE_FILE=$3
#rm output.yaml
#aws cloudformation delete-stack --stack-name swagger03
USE_MSG="Usage: deploy.sh S3_BUCKET STACK_NAME"
if [ -z "$S3_BUCKET" ]; then
echo "Missing S3_BUCKET and STACK_NAME"
echo $USE_MSG
exit 1
fi
if [ -z "$STACK_NAME" ]; then
echo "Missing STACK_NAME"
echo $USE_MSG
exit 1
fi
if [ -z "$TEMPLATE_FILE" ]; then
echo "Missing TEMPLATE_FILE"
echo $USE_MSG
exit 1
fi
# upload to S3
aws cloudformation package --template-file $TEMPLATE_FILE --s3-bucket $S3_BUCKET --output-template-file output.yaml
# deploy to cloud formation
aws cloudformation deploy --template-file output.yaml --stack-name $STACK_NAME --capabilities CAPABILITY_IAM $4 $5 $6 $7
# get API endpoint
API_ENDPOINT=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --query 'Stacks[0].Outputs[0].OutputValue')
# remove quotes
API_ENDPOINT=$(sed -e 's/^"//' -e 's/"$//' <<< $API_ENDPOINT)
# remove temp yaml files
rm output.yml
rm output.yaml
echo ""
echo "Test in browser: $API_ENDPOINT"
echo ""
echo "To Delete the Stack use this command"
echo "aws cloudformation delete-stack --stack-name $STACK_NAME &"