-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy
executable file
·41 lines (31 loc) · 889 Bytes
/
deploy
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
#!/usr/bin/env bash
set -euxo pipefail
TARGET=$1
AUTO_APPROVE_TF=${AUTO_APPROVE_TF:-false}
CREATE_INVALIDATION=${CREATE_INVALIDATION:-true}
AWS_EXECUTABLE=${AWS_EXECUTABLE:-aws}
echo "TERRAFORM VERSION"
terraform version
if [[ "$AUTO_APPROVE_TF" == "true" ]]; then
TERRAFORM_ARGS='-auto-approve'
(
cd infra/$TARGET
terraform plan
)
else
TERRAFORM_ARGS=''
fi
(
cd infra/$TARGET
terraform apply $TERRAFORM_ARGS
)
set +x
FRONTEND_BUCKET=$(cd infra/$TARGET && terraform output frontendbucket | sed 's/"//g')
set -x
$AWS_EXECUTABLE s3 sync frontend/build s3://$FRONTEND_BUCKET
if [[ "$CREATE_INVALIDATION" == "true" ]]; then
set +x
DISTRIBUTION_ID=$(cd infra/$TARGET && terraform output cloudfront | sed 's/"//g')
set -x
$AWS_EXECUTABLE cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/index.html"
fi