-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtofu-plan
More file actions
executable file
·50 lines (44 loc) · 1.36 KB
/
tofu-plan
File metadata and controls
executable file
·50 lines (44 loc) · 1.36 KB
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
#!/bin/bash
# Run tofu plan across all services. Used in the tofu-plan and tofu-apply workflows.
repo_root="$(git rev-parse --show-toplevel)"
script_dir="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
job_error=false
temp_plan_out=$(mktemp)
for dir in $(ls "$repo_root/terraform/services"); do
cd "$repo_root/terraform/services/$dir"
[ ! -f "conf.sh" ] && echo "Skipping $dir service due to no conf.sh file" && continue
set -a
source conf.sh
set +a
case "$TARGET_ENVS" in
all)
echo "Planning $dir service because it exists in all environments, including $APP-$ENV"
;;
account)
if [[ "$APP" == "bcda" && ("$ENV" == "test" || "$ENV" == "prod") ]]; then
echo "Planning $dir service for the account-wide $APP-$ENV environment"
else
echo "Skipping $dir service because $APP-$ENV is not an account-wide environment"
continue
fi
;;
*)
in_set=false
for infra_env in $TARGET_ENVS; do
if [ "$infra_env" == "$APP-$ENV" ]; then
in_set=true
fi
done
if [ "$in_set" == true ]; then
echo "Planning $dir service because $APP-$ENV is in the set"
else
echo "Skipping $dir service because $APP-$ENV is not in the set"
continue
fi
;;
esac
source $script_dir/lib/tofu-run.sh
done
if [ "$job_error" == "true" ]; then
exit 1
fi