-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_deploy_aws
executable file
·87 lines (61 loc) · 1.75 KB
/
_deploy_aws
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#! /bin/bash
#
# -------------------
# What's This Script?
# -------------------
# Once you've provisioned your aws resources with `_run_terraform`
# we use the aws-cli to sync output of our ng app to production S3 buckets
#
clear
source .env
# If no argument supplied, prompt user to choose deployment
deploy_option=$1
if [[ -z $deploy_option ]]; then
echo -e """
===============================================================
Choose a number for deploying the present contents of 'dist-client':
1. dev
2. prod (requires confirmation)
===============================================================
"""
read deploy_option
fi
# Validate $deploy_option
if [[ $deploy_option =~ ^[0-9]+$ && $deploy_option -ge 1 && $deploy_option -le 2 ]]; then
# Set params based on choice of $deploy_option
if [[ $deploy_option = 1 ]]; then
clear
echo "Deploying to dev..."
sleep 1
bucket_name="$TF_VAR_PREFIX""$TF_VAR_DEV_BUCKET_NAME"
fi
if [[ $deploy_option = 2 ]]; then
clear
echo "Deploying to prod..."
sleep 1
bucket_name="$TF_VAR_PREFIX""$TF_VAR_PROD_BUCKET_NAME"
fi
else
echo "You need to choose 1 or 2"
exit
fi
# User must confirm changes to prod
if [[ $deploy_option = 2 ]]; then
echo -e """
===============================================================
Are you \033[31m100%\033[0m certain you want to update prod frontend?
Type 'yes' to proceed.
===============================================================
"""
read decision
if [[ $decision != 'yes' ]]; then
echo "Cancelling deployment to prod"
exit
fi
fi
# Remove everything from bucket
aws s3 rm s3://${bucket_name} --recursive
# Sync dist with bucket
aws s3 sync ./dist/ s3://${bucket_name}/
# Final printout
./_show_website_endpoints