File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
examples/existing-cluster-with-base-and-infra Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -o errexit
3+ set -o pipefail
4+
5+ read -p " Enter the region: " region
6+ export AWS_DEFAULT_REGION=$region
7+
8+ targets=(
9+ " module.eks_monitoring"
10+ )
11+
12+ for target in " ${targets[@]} "
13+ do
14+ terraform destroy -target=" $target " -auto-approve
15+ destroy_output=$( terraform destroy -target=" $target " -auto-approve 2>&1 )
16+ if [[ $? -eq 0 && $destroy_output == * " Destroy complete!" * ]]; then
17+ echo " SUCCESS: Terraform destroy of $target completed successfully"
18+ else
19+ echo " FAILED: Terraform destroy of $target failed"
20+ exit 1
21+ fi
22+ done
23+
24+ terraform destroy -auto-approve
25+ destroy_output=$( terraform destroy -auto-approve 2>&1 )
26+ if [[ $? -eq 0 && $destroy_output == * " Destroy complete!" * ]]; then
27+ echo " SUCCESS: Terraform destroy of all targets completed successfully"
28+ else
29+ echo " FAILED: Terraform destroy of all targets failed"
30+ exit 1
31+ fi
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ echo " Initializing ..."
4+ terraform init || echo " \" terraform init\" failed"
5+
6+ # List of Terraform modules to apply in sequence
7+ targets=(
8+ " module.eks_monitoring"
9+ )
10+
11+ # Apply modules in sequence
12+ for target in " ${targets[@]} "
13+ do
14+ echo " Applying module $target ..."
15+ apply_output=$( terraform apply -target=" $target " -auto-approve 2>&1 | tee /dev/tty)
16+ if [[ ${PIPESTATUS[0]} -eq 0 && $apply_output == * " Apply complete" * ]]; then
17+ echo " SUCCESS: Terraform apply of $target completed successfully"
18+ else
19+ echo " FAILED: Terraform apply of $target failed"
20+ exit 1
21+ fi
22+ done
23+
24+ # Final apply to catch any remaining resources
25+ echo " Applying remaining resources..."
26+ apply_output=$( terraform apply -auto-approve 2>&1 | tee /dev/tty)
27+ if [[ ${PIPESTATUS[0]} -eq 0 && $apply_output == * " Apply complete" * ]]; then
28+ echo " SUCCESS: Terraform apply of all modules completed successfully"
29+ else
30+ echo " FAILED: Terraform apply of all modules failed"
31+ exit 1
32+ fi
You can’t perform that action at this time.
0 commit comments