-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Installing and Cleanup scripts for remote bash execution
- Loading branch information
1 parent
995505d
commit 2609106
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
set -o pipefail | ||
|
||
read -p "Enter the region: " region | ||
export AWS_DEFAULT_REGION=$region | ||
|
||
targets=( | ||
"module.eks_monitoring" | ||
) | ||
|
||
for target in "${targets[@]}" | ||
do | ||
terraform destroy -target="$target" -auto-approve | ||
destroy_output=$(terraform destroy -target="$target" -auto-approve 2>&1) | ||
if [[ $? -eq 0 && $destroy_output == *"Destroy complete!"* ]]; then | ||
echo "SUCCESS: Terraform destroy of $target completed successfully" | ||
else | ||
echo "FAILED: Terraform destroy of $target failed" | ||
exit 1 | ||
fi | ||
done | ||
|
||
terraform destroy -auto-approve | ||
destroy_output=$(terraform destroy -auto-approve 2>&1) | ||
if [[ $? -eq 0 && $destroy_output == *"Destroy complete!"* ]]; then | ||
echo "SUCCESS: Terraform destroy of all targets completed successfully" | ||
else | ||
echo "FAILED: Terraform destroy of all targets failed" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
echo "Initializing ..." | ||
terraform init || echo "\"terraform init\" failed" | ||
|
||
# List of Terraform modules to apply in sequence | ||
targets=( | ||
"module.eks_monitoring" | ||
) | ||
|
||
# Apply modules in sequence | ||
for target in "${targets[@]}" | ||
do | ||
echo "Applying module $target..." | ||
apply_output=$(terraform apply -target="$target" -auto-approve 2>&1 | tee /dev/tty) | ||
if [[ ${PIPESTATUS[0]} -eq 0 && $apply_output == *"Apply complete"* ]]; then | ||
echo "SUCCESS: Terraform apply of $target completed successfully" | ||
else | ||
echo "FAILED: Terraform apply of $target failed" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Final apply to catch any remaining resources | ||
echo "Applying remaining resources..." | ||
apply_output=$(terraform apply -auto-approve 2>&1 | tee /dev/tty) | ||
if [[ ${PIPESTATUS[0]} -eq 0 && $apply_output == *"Apply complete"* ]]; then | ||
echo "SUCCESS: Terraform apply of all modules completed successfully" | ||
else | ||
echo "FAILED: Terraform apply of all modules failed" | ||
exit 1 | ||
fi |