-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.sh
executable file
·49 lines (36 loc) · 1.48 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
#!/bin/bash
set -xe
if [[ ! -f $1 ]]; then
echo "$1 is not a file, please provide a path to a variables file."
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
terraform init
# deploy EKS, RDS
terraform apply -var-file=$1 --target=module.gcp
management_api=$(sed -En 's|'management_api'[[:space:]]+=[[:space:]]+"(.+)"|\1|p' $1)
if [[ "${management_api}" != "public" ]]; then
BASTION=$(sed -En 's|'deployment_id'[[:space:]]+=[[:space:]]+"(.+)"|\1|p' $1)-bastion
ZONE=$(gcloud compute instances list --filter="name=('$BASTION')" --format 'csv[no-heading](zone)')
gcloud beta compute ssh --zone ${ZONE} ${BASTION} --tunnel-through-iap --ssh-flag='-L 1234:127.0.0.1:8888 -C -N' &
PROXY_PID=$!
# similar to 'finally' in Python
function finish {
# Your cleanup code here
kill ${PROXY_PID}
}
trap finish EXIT
sleep 5 # give the proxy time to establish
# Need this to still be able to access Terraform remote state.
# Otherwise Terraform would error saying it could connect to remote backend
export no_proxy="googleapis.com,.google.com,metadata,.googleapis.com,.acme-v02.api.letsencrypt.org,acme-v02.api.letsencrypt.org"
export https_proxy=http://127.0.0.1:1234
fi
# install Tiller in the cluster
terraform apply -var-file=$1 --target=module.system_components
# install astronomer in the cluster
terraform apply -var-file=$1 --target=module.astronomer
if [[ "${management_api}" != "public" ]]; then
# Clear Proxy Variables
unset no_proxy https_proxy
fi