forked from aws-samples/terraform-ssp-eks-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtf-init-examples.sh
26 lines (20 loc) · 846 Bytes
/
tf-init-examples.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
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# This script can be used to easily run terraform init against all the exampels
# Can be useful to verify that all the examples init properly (e.g. providers versions errors)
EXCLUDE_DIRS=(
"! -path *.terraform*"
"! -path */gitlab-ci-cd/*"
)
# Find all main.tf files in the current directory and all subdirectories.
main_tf_locations=$(find . -name 'main.tf' ${EXCLUDE_DIRS[@]} -exec dirname {} \; | sort -u)
#Print the list of main.tf files
echo "main.tf files found:"
echo "$main_tf_locations"
# Terraform init for every main.tf folder location.
for location in $main_tf_locations; do
echo "###### Verifying TF Init for $location ##########"
terraform -chdir=$location init
echo "##################################################"
done