This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
deploy.sh
executable file
·54 lines (42 loc) · 1.54 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
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
./prerequisites.sh
RETURN=$?
if [ $RETURN -ne 0 ];
then
exit 1
fi
echo "Did you configure the variables.tf properly? (y/n)"
read -r config
if [ "$config" != "y" ]; then
echo "Please configure the variables.tf before deploying the solution"
exit 1
fi
account=$(aws sts get-caller-identity --query Account --output text);
if [ -z "$account" ]; then
echo "Could not get target account to deploy on. Make sure aws cli credentials are properly configured."
exit 1
fi
echo "You are about to deploy the solution on the account $account, proceed? (y/n)"
read -r deploy
if [ "$deploy" = "y" ]; then
# Deploy the terraform stack
echo "======================================"
echo "===== Infrastructure deployment ======"
echo "======================================"
terraform init && terraform apply --auto-approve
terraform_result=$?
# Deploy the frontend
if [ $terraform_result -ne 0 ]; then
echo "There were some errors during the deployment, please refer to the troubleshooting guide in the README and retry."
else
# Retrieve outputs
frontend_bucket=$(terraform output -raw frontend_bucket)
frontend_distribution_id=$(terraform output -raw frontend_distribution_id)
echo "======================================"
echo "====== Frontend deployment ======="
echo "======================================"
cd ../web-portal && ./deploy.sh -y -s "$frontend_bucket" -d "$frontend_distribution_id"
fi
fi