-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflow.sh
65 lines (48 loc) · 1.73 KB
/
workflow.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
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Default plan file name
PLANFILE=${1:-planfile}
# Optional apply flag (use --apply or --no-apply as the second argument)
APPLY_FLAG=${2:-}
# Define escape codes for red and bold text
RED="\033[31m"
BOLD="\033[1m"
RESET="\033[0m"
# Print the styled text
echo -e "${BOLD}${RED}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${RESET}"
echo -e "${BOLD}${RED}
___ ______ ___ ____ ____
/ \ \ / / ___| |_ _| _ \| _ \
/ _ \ \ /\ / /\___ \ | || | | | |_) |
/ ___ \ V V / ___) | | || |_| | __/
/_/ \_\_/\_/ |____/ |___|____/|_|
${RESET}"
echo "An AWS Backed Intelligent Document Processing Solution"
echo "HK Transfield, 2024"
echo -e "${BOLD}${RED}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${RESET}"
terraform init
echo "Validating Terraform configuration..."
terraform validate
echo "Planning Terraform changes..."
terraform plan -out="$PLANFILE"
# Determine if the plan should be applied
if [[ "$APPLY_FLAG" == "--apply" ]]; then
echo "Applying Terraform changes..."
terraform apply "$PLANFILE"
# DATA_BUCKET = "$(terraform output -raw data_bucket)"
# aws s3 cp classification-training s3://{data_bucket}/idp/textract --recursive --only-show-errors
elif [[ "$APPLY_FLAG" == "--no-apply" ]]; then
echo "Skipping Terraform apply."
else
# Interactive prompt if no flag is provided
read -p "Do you want to apply the plan? (yes/no): " RESPONSE
if [[ "$RESPONSE" == "yes" ]]; then
echo "Applying Terraform changes..."
terraform apply "$PLANFILE"
else
echo "Skipping Terraform apply."
fi
fi
cd app
python -m streamlit run app.py